-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are a few issues with the tests causing them to fail with Node 6 and above: * When parsing regular expression literals with the `y` and `u` flags, espree expected the `value` property of the resulting `Literal` node to `null`. However, since Node 6+ supports these flags, the `value` property was actually a regular expression with the corresponding flags. This commit updates the tests to conditionally expect a regex or `null` depending on whether the flags are supported in the current environment. * For invalid regular expressions with the `u` flag, Acorn outputs a different error message depending on whether the current environment supports the `u` flag. This commit updates the tests to conditionally expect a particular error message depending on whether the current environment supports the `u` flag.
- Loading branch information
1 parent
d7fb9d1
commit a3442b5
Showing
7 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,7 @@ node_js: | |
- "0.12" | ||
- 4 | ||
- 5 | ||
- 6 | ||
- 7 | ||
after_success: | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 25 additions & 6 deletions
31
tests/fixtures/ecma-version/6/regexUFlag/regex-u-invalid-extended-escape.result.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
module.exports = { | ||
"index": 12, | ||
"lineNumber": 1, | ||
"column": 13, | ||
"message": "Code point out of bounds" | ||
}; | ||
function uFlagSupported() { | ||
try { | ||
RegExp("", "u"); // eslint-disable-line no-invalid-regexp | ||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
} | ||
|
||
// Acorn's parsing error is different depending on whether the environment supports the regex u flag. | ||
if (uFlagSupported()) { | ||
module.exports = { | ||
"index": 9, | ||
"lineNumber": 1, | ||
"column": 10, | ||
"message": "Error parsing regular expression: Invalid regular expression: /\\u{110000}/: Invalid unicode escape" | ||
}; | ||
} else { | ||
module.exports = { | ||
"index": 12, | ||
"lineNumber": 1, | ||
"column": 13, | ||
"message": "Code point out of bounds" | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
module.exports = function(literalNode) { | ||
if (literalNode.regex) { | ||
try { | ||
literalNode.value = new RegExp(literalNode.regex.pattern, literalNode.regex.flags); | ||
} catch (e) { | ||
literalNode.value = null; | ||
} | ||
} | ||
return literalNode; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,6 @@ module.exports = { | |
|
||
} | ||
|
||
assert.deepEqual(result, expected); | ||
assert.deepEqual(result, getRaw(expected)); | ||
} | ||
}; |