2010-12-29 05:48:54 +00:00
|
|
|
|
# Regular Expression Literals
|
|
|
|
|
# ---------------------------
|
|
|
|
|
|
2011-01-03 09:17:00 +00:00
|
|
|
|
# TODO: add method invocation tests: /regex/.toString()
|
|
|
|
|
|
2010-12-29 19:06:57 +00:00
|
|
|
|
# * Regexen
|
|
|
|
|
# * Heregexen
|
|
|
|
|
|
2010-12-29 05:48:54 +00:00
|
|
|
|
test "basic regular expression literals", ->
|
|
|
|
|
ok 'a'.match(/a/)
|
|
|
|
|
ok 'a'.match /a/
|
|
|
|
|
ok 'a'.match(/a/g)
|
|
|
|
|
ok 'a'.match /a/g
|
|
|
|
|
|
|
|
|
|
test "division is not confused for a regular expression", ->
|
2015-01-10 00:48:00 +00:00
|
|
|
|
# Any spacing around the slash is allowed when it cannot be a regex.
|
2010-12-29 05:48:54 +00:00
|
|
|
|
eq 2, 4 / 2 / 1
|
2015-01-10 00:48:00 +00:00
|
|
|
|
eq 2, 4/2/1
|
|
|
|
|
eq 2, 4/ 2 / 1
|
|
|
|
|
eq 2, 4 /2 / 1
|
|
|
|
|
eq 2, 4 / 2/ 1
|
|
|
|
|
eq 2, 4 / 2 /1
|
|
|
|
|
eq 2, 4 /2/ 1
|
|
|
|
|
|
|
|
|
|
a = (regex) -> regex.test 'a b c'
|
|
|
|
|
a.valueOf = -> 4
|
2010-12-29 05:48:54 +00:00
|
|
|
|
b = 2
|
|
|
|
|
g = 1
|
|
|
|
|
|
2015-01-10 00:48:00 +00:00
|
|
|
|
eq 2, a / b/g
|
|
|
|
|
eq 2, a/ b/g
|
|
|
|
|
eq 2, a / b/ g
|
|
|
|
|
eq 2, a / b/g # Tabs.
|
|
|
|
|
eq 2, a / b/g # Non-breaking spaces.
|
|
|
|
|
eq true, a /b/g
|
|
|
|
|
# Use parentheses to disambiguate.
|
|
|
|
|
eq true, a(/ b/g)
|
|
|
|
|
eq true, a(/ b/)
|
|
|
|
|
eq true, a (/ b/)
|
|
|
|
|
# Escape to disambiguate.
|
|
|
|
|
eq true, a /\ b/g
|
|
|
|
|
eq false, a /\ b/g
|
|
|
|
|
eq true, a /\ b/
|
2011-04-23 17:33:35 +00:00
|
|
|
|
|
2010-12-29 05:48:54 +00:00
|
|
|
|
obj = method: -> 2
|
|
|
|
|
two = 2
|
|
|
|
|
eq 2, (obj.method()/two + obj.method()/two)
|
|
|
|
|
|
|
|
|
|
i = 1
|
|
|
|
|
eq 2, (4)/2/i
|
|
|
|
|
eq 1, i/i/i
|
|
|
|
|
|
2015-01-10 00:48:00 +00:00
|
|
|
|
a = ''
|
|
|
|
|
a += ' ' until / /.test a
|
|
|
|
|
eq a, ' '
|
|
|
|
|
|
|
|
|
|
a = if /=/.test '=' then yes else no
|
|
|
|
|
eq a, yes
|
|
|
|
|
|
|
|
|
|
a = if !/=/.test '=' then yes else no
|
|
|
|
|
eq a, no
|
|
|
|
|
|
|
|
|
|
#3182:
|
|
|
|
|
match = 'foo=bar'.match /=/
|
|
|
|
|
eq match[0], '='
|
|
|
|
|
|
|
|
|
|
#3410:
|
|
|
|
|
ok ' '.match(/ /)[0] is ' '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "division vs regex after a callable token", ->
|
|
|
|
|
b = 2
|
|
|
|
|
g = 1
|
|
|
|
|
r = (r) -> r.test 'b'
|
|
|
|
|
|
|
|
|
|
a = 4
|
|
|
|
|
eq 2, a / b/g
|
|
|
|
|
eq 2, a/b/g
|
|
|
|
|
eq 2, a/ b/g
|
|
|
|
|
eq true, r /b/g
|
|
|
|
|
eq 2, (1 + 3) / b/g
|
|
|
|
|
eq 2, (1 + 3)/b/g
|
|
|
|
|
eq 2, (1 + 3)/ b/g
|
|
|
|
|
eq true, (r) /b/g
|
|
|
|
|
eq 2, [4][0] / b/g
|
|
|
|
|
eq 2, [4][0]/b/g
|
|
|
|
|
eq 2, [4][0]/ b/g
|
|
|
|
|
eq true, [r][0] /b/g
|
|
|
|
|
eq 0.5, 4? / b/g
|
|
|
|
|
eq 0.5, 4?/b/g
|
|
|
|
|
eq 0.5, 4?/ b/g
|
|
|
|
|
eq true, r? /b/g
|
|
|
|
|
(->
|
|
|
|
|
eq 2, @ / b/g
|
|
|
|
|
eq 2, @/b/g
|
|
|
|
|
eq 2, @/ b/g
|
|
|
|
|
).call 4
|
|
|
|
|
(->
|
|
|
|
|
eq true, @ /b/g
|
|
|
|
|
).call r
|
|
|
|
|
(->
|
|
|
|
|
eq 2, this / b/g
|
|
|
|
|
eq 2, this/b/g
|
|
|
|
|
eq 2, this/ b/g
|
|
|
|
|
).call 4
|
|
|
|
|
(->
|
|
|
|
|
eq true, this /b/g
|
|
|
|
|
).call r
|
|
|
|
|
class A
|
|
|
|
|
p: (regex) -> if regex then r regex else 4
|
|
|
|
|
class B extends A
|
|
|
|
|
p: ->
|
[CS2] Compile all super calls to ES2015 super (#4424)
* Compile all super calls to ES2015 super
This breaks using `super` in non-methods, meaning several tests are
failing. Self-compilation still works.
* Use bound functions for IIFEs containing `super`
`super` can only be called directly in a method, or in an arrow
function.
* Fix handling of `class @A extends A`
This behaviour worked 'for free' when the parent reference was being
cached by the executable class body wrapper. There now needs to be
special handling in place to check if the parent name matches the class
name, and if so to cache the parent reference.
* Fix tests broken by compiling ES2015 `super`
* Disallow bare super
This removes syntax support for 'bare' super calls, e.g.:
class B extends A
constructor: -> super
`super` must now always be followed with arguments like a regular
function call. This also removes the capability of implicitly forwarding
arguments. The above can be equivalently be written as:
class B extends A
constructor: -> super arguments...
* Support super with accessors
`super` with following accessor(s) is now compiled to ES2015
equivalents. In particular, expressions such as `super.name`,
`super[name]`, and also `super.name.prop` are all now valid, and can be
used as expected as calls (i.e. `super.name()`) or in expressions (i.e.
`if super.name? ...`).
`super` without accessors is compiled to a constructor super call in a
constructor, and otherwise, as before, to a super call to the method of
the same name, i.e.
speak: -> super()
...is equivalent to
speak: -> super.speak()
A neat side-effect of the changes is that existential calls now work
properly with super, meaning `super?()` will only call if the super
property exists (and is a function). This is not valid for super in
constructors.
* Prevent calling `super` methods with `new`
This fixes a bug in the previous super handling whereby using the `new`
operator with a `super` call would silently drop the `new`. This is now
an explicit compiler error, as it is invalid JS at runtime.
* Clean up some old super handling code
This was mostly code for tracking the source classes and variables for
methods, which were needed to build the old lookups on `__super__`.
* Add TODO to improve bare super parse error
* Add some TODOs to improve some of the class tests
2017-02-04 20:03:17 +00:00
|
|
|
|
eq 2, super() / b/g
|
|
|
|
|
eq 2, super()/b/g
|
|
|
|
|
eq 2, super()/ b/g
|
2015-01-10 00:48:00 +00:00
|
|
|
|
eq true, super /b/g
|
|
|
|
|
new B().p()
|
|
|
|
|
|
|
|
|
|
test "always division and never regex after some tokens", ->
|
|
|
|
|
b = 2
|
|
|
|
|
g = 1
|
|
|
|
|
|
|
|
|
|
eq 2, 4 / b/g
|
|
|
|
|
eq 2, 4/b/g
|
|
|
|
|
eq 2, 4/ b/g
|
|
|
|
|
eq 2, 4 /b/g
|
|
|
|
|
eq 2, "4" / b/g
|
|
|
|
|
eq 2, "4"/b/g
|
|
|
|
|
eq 2, "4"/ b/g
|
|
|
|
|
eq 2, "4" /b/g
|
2015-01-14 20:27:24 +00:00
|
|
|
|
eq 20, "4#{0}" / b/g
|
|
|
|
|
eq 20, "4#{0}"/b/g
|
|
|
|
|
eq 20, "4#{0}"/ b/g
|
|
|
|
|
eq 20, "4#{0}" /b/g
|
2015-01-10 00:48:00 +00:00
|
|
|
|
ok isNaN /a/ / b/g
|
|
|
|
|
ok isNaN /a/i / b/g
|
|
|
|
|
ok isNaN /a//b/g
|
|
|
|
|
ok isNaN /a/i/b/g
|
|
|
|
|
ok isNaN /a// b/g
|
|
|
|
|
ok isNaN /a/i/ b/g
|
|
|
|
|
ok isNaN /a/ /b/g
|
|
|
|
|
ok isNaN /a/i /b/g
|
|
|
|
|
eq 0.5, true / b/g
|
|
|
|
|
eq 0.5, true/b/g
|
|
|
|
|
eq 0.5, true/ b/g
|
|
|
|
|
eq 0.5, true /b/g
|
|
|
|
|
eq 0, false / b/g
|
|
|
|
|
eq 0, false/b/g
|
|
|
|
|
eq 0, false/ b/g
|
|
|
|
|
eq 0, false /b/g
|
|
|
|
|
eq 0, null / b/g
|
|
|
|
|
eq 0, null/b/g
|
|
|
|
|
eq 0, null/ b/g
|
|
|
|
|
eq 0, null /b/g
|
|
|
|
|
ok isNaN undefined / b/g
|
|
|
|
|
ok isNaN undefined/b/g
|
|
|
|
|
ok isNaN undefined/ b/g
|
|
|
|
|
ok isNaN undefined /b/g
|
|
|
|
|
ok isNaN {a: 4} / b/g
|
|
|
|
|
ok isNaN {a: 4}/b/g
|
|
|
|
|
ok isNaN {a: 4}/ b/g
|
|
|
|
|
ok isNaN {a: 4} /b/g
|
|
|
|
|
o = prototype: 4
|
|
|
|
|
eq 2, o:: / b/g
|
|
|
|
|
eq 2, o::/b/g
|
|
|
|
|
eq 2, o::/ b/g
|
|
|
|
|
eq 2, o:: /b/g
|
|
|
|
|
i = 4
|
|
|
|
|
eq 2.0, i++ / b/g
|
|
|
|
|
eq 2.5, i++/b/g
|
|
|
|
|
eq 3.0, i++/ b/g
|
|
|
|
|
eq 3.5, i++ /b/g
|
|
|
|
|
eq 4.0, i-- / b/g
|
|
|
|
|
eq 3.5, i--/b/g
|
|
|
|
|
eq 3.0, i--/ b/g
|
|
|
|
|
eq 2.5, i-- /b/g
|
|
|
|
|
|
|
|
|
|
test "compound division vs regex", ->
|
|
|
|
|
c = 4
|
|
|
|
|
i = 2
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a /= c / i
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a /= c /i
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a /= c /i # Tabs.
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a /= c /i # Non-breaking spaces.
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a/= c /i
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = 10
|
|
|
|
|
b = a/=c/i
|
|
|
|
|
eq a, 5
|
|
|
|
|
|
|
|
|
|
a = (regex) -> regex.test '=C '
|
|
|
|
|
b = a /=c /i
|
|
|
|
|
eq b, true
|
|
|
|
|
|
|
|
|
|
a = (regex) -> regex.test '= C '
|
|
|
|
|
# Use parentheses to disambiguate.
|
|
|
|
|
b = a(/= c /i)
|
|
|
|
|
eq b, true
|
|
|
|
|
b = a(/= c /)
|
|
|
|
|
eq b, false
|
|
|
|
|
b = a (/= c /)
|
|
|
|
|
eq b, false
|
|
|
|
|
# Escape to disambiguate.
|
|
|
|
|
b = a /\= c /i
|
|
|
|
|
eq b, true
|
|
|
|
|
b = a /\= c /
|
|
|
|
|
eq b, false
|
|
|
|
|
|
2010-12-29 05:48:54 +00:00
|
|
|
|
test "#764: regular expressions should be indexable", ->
|
|
|
|
|
eq /0/['source'], ///#{0}///['source']
|
|
|
|
|
|
|
|
|
|
test "#584: slashes are allowed unescaped in character classes", ->
|
|
|
|
|
ok /^a\/[/]b$/.test 'a//b'
|
|
|
|
|
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 22:40:43 +00:00
|
|
|
|
test "does not allow to escape newlines", ->
|
|
|
|
|
throws -> CoffeeScript.compile '/a\\\nb/'
|
2011-09-22 08:09:58 +00:00
|
|
|
|
|
2010-12-29 05:48:54 +00:00
|
|
|
|
|
2011-03-12 02:41:12 +00:00
|
|
|
|
# Heregexe(n|s)
|
2010-12-29 05:48:54 +00:00
|
|
|
|
|
|
|
|
|
test "a heregex will ignore whitespace and comments", ->
|
|
|
|
|
eq /^I'm\x20+[a]\s+Heregex?\/\/\//gim + '', ///
|
|
|
|
|
^ I'm \x20+ [a] \s+
|
|
|
|
|
Heregex? / // # or not
|
|
|
|
|
///gim + ''
|
|
|
|
|
|
|
|
|
|
test "an empty heregex will compile to an empty, non-capturing group", ->
|
|
|
|
|
eq /(?:)/ + '', /// /// + ''
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 22:40:43 +00:00
|
|
|
|
eq /(?:)/ + '', ////// + ''
|
|
|
|
|
|
|
|
|
|
test "heregex starting with slashes", ->
|
|
|
|
|
ok /////a/\////.test ' //a// '
|
|
|
|
|
|
|
|
|
|
test '#2388: `///` in heregex interpolations', ->
|
|
|
|
|
ok ///a#{///b///}c///.test ' /a/b/c/ '
|
|
|
|
|
ws = ' \t'
|
|
|
|
|
scan = (regex) -> regex.exec('\t foo')[0]
|
|
|
|
|
eq '/\t /', /// #{scan /// [#{ws}]* ///} /// + ''
|
2011-09-22 08:39:13 +00:00
|
|
|
|
|
2015-01-15 18:44:14 +00:00
|
|
|
|
test "regexes are not callable", ->
|
|
|
|
|
throws -> CoffeeScript.compile '/a/()'
|
|
|
|
|
throws -> CoffeeScript.compile '///a#{b}///()'
|
|
|
|
|
throws -> CoffeeScript.compile '/a/ 1'
|
|
|
|
|
throws -> CoffeeScript.compile '///a#{b}/// 1'
|
|
|
|
|
throws -> CoffeeScript.compile '''
|
|
|
|
|
/a/
|
|
|
|
|
k: v
|
|
|
|
|
'''
|
|
|
|
|
throws -> CoffeeScript.compile '''
|
|
|
|
|
///a#{b}///
|
|
|
|
|
k: v
|
|
|
|
|
'''
|
2015-02-05 16:23:03 +00:00
|
|
|
|
|
|
|
|
|
test "backreferences", ->
|
|
|
|
|
ok /(a)(b)\2\1/.test 'abba'
|
|
|
|
|
|
|
|
|
|
test "#3795: Escape otherwise invalid characters", ->
|
|
|
|
|
ok (/
/).test '\u2028'
|
|
|
|
|
ok (/
/).test '\u2029'
|
|
|
|
|
ok ///\
///.test '\u2028'
|
|
|
|
|
ok ///\
///.test '\u2029'
|
|
|
|
|
ok ///a
b///.test 'ab' # The space is U+2028.
|
|
|
|
|
ok ///a
b///.test 'ab' # The space is U+2029.
|
|
|
|
|
ok ///\0
|
|
|
|
|
1///.test '\x001'
|
|
|
|
|
|
|
|
|
|
a = 'a'
|
|
|
|
|
ok ///#{a}
b///.test 'ab' # The space is U+2028.
|
|
|
|
|
ok ///#{a}
b///.test 'ab' # The space is U+2029.
|
|
|
|
|
ok ///#{a}\
///.test 'a\u2028'
|
|
|
|
|
ok ///#{a}\
///.test 'a\u2029'
|
|
|
|
|
ok ///#{a}\0
|
|
|
|
|
1///.test 'a\x001'
|
2017-04-20 06:03:06 +00:00
|
|
|
|
|
|
|
|
|
test "#4248: Unicode code point escapes", ->
|
|
|
|
|
ok /a\u{1ab}c/u.test 'a\u01abc'
|
|
|
|
|
ok ///#{ 'a' }\u{000001ab}c///u.test 'a\u{1ab}c'
|
|
|
|
|
ok ///a\u{000001ab}c///u.test 'a\u{1ab}c'
|
|
|
|
|
ok /a\u{12345}c/u.test 'a\ud808\udf45c'
|
|
|
|
|
|
|
|
|
|
# and now without u flag
|
|
|
|
|
ok /a\u{1ab}c/.test 'a\u01abc'
|
|
|
|
|
ok ///#{ 'a' }\u{000001ab}c///.test 'a\u{1ab}c'
|
|
|
|
|
ok ///a\u{000001ab}c///.test 'a\u{1ab}c'
|
|
|
|
|
ok /a\u{12345}c/.test 'a\ud808\udf45c'
|
|
|
|
|
|
2017-04-25 17:15:08 +00:00
|
|
|
|
# rewrite code point escapes unless u flag is set
|
2017-06-07 06:33:46 +00:00
|
|
|
|
eqJS """
|
2017-04-20 06:03:06 +00:00
|
|
|
|
/\\u{bcdef}\\u{abc}/u
|
2017-06-07 06:33:46 +00:00
|
|
|
|
""",
|
|
|
|
|
"""
|
2017-04-25 17:15:08 +00:00
|
|
|
|
/\\u{bcdef}\\u{abc}/u;
|
2017-04-20 06:03:06 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2017-06-07 06:33:46 +00:00
|
|
|
|
eqJS """
|
2017-04-20 06:03:06 +00:00
|
|
|
|
///#{ 'a' }\\u{bcdef}///
|
2017-06-07 06:33:46 +00:00
|
|
|
|
""",
|
|
|
|
|
"""
|
2017-04-20 06:03:06 +00:00
|
|
|
|
/a\\udab3\\uddef/;
|
|
|
|
|
"""
|
2017-12-03 19:55:26 +00:00
|
|
|
|
|
|
|
|
|
test "#4811, heregex comments with ///", ->
|
|
|
|
|
eqJS """
|
|
|
|
|
///
|
|
|
|
|
a | # comment with ///
|
|
|
|
|
b # /// 'heregex' in comment will be consumed
|
|
|
|
|
///
|
|
|
|
|
""",
|
|
|
|
|
"""
|
|
|
|
|
// comment with ///
|
|
|
|
|
// /// 'heregex' in comment will be consumed
|
|
|
|
|
/a|b/;
|
|
|
|
|
"""
|