diff options
author | Daniel Ehrenberg <littledan@chromium.org> | 2017-10-13 20:16:16 +0200 |
---|---|---|
committer | Leo Balter <leonardo.balter@gmail.com> | 2017-10-13 14:16:16 -0400 |
commit | e6df79231da4d3305afd63c0ea0941005d7cc2f2 (patch) | |
tree | 3e134be7905bd65179d9a677cfa374c853f06547 /test/built-ins/RegExp/named-groups/string-replace-unclosed.js | |
parent | 56e02611d4388e0b7b6461ac4233944fc7b84cb4 (diff) | |
download | qtdeclarative-testsuites-e6df79231da4d3305afd63c0ea0941005d7cc2f2.tar.gz |
Update RegExp named capture tests for spec change (#1270)
The RegExp named groups specification has changed to not throw
errors in certain cases. This patch updates the test262 tests to match
the new specification, and throws in an additional test that verifies
the interaction between named group syntax and other replacement.
The tests pass on a version of V8 which implements the new semantics.
https://github.com/tc39/proposal-regexp-named-groups/commit/92ceba518c2ab0d2811c2efa8248ed1b3f8b5506
Diffstat (limited to 'test/built-ins/RegExp/named-groups/string-replace-unclosed.js')
-rw-r--r-- | test/built-ins/RegExp/named-groups/string-replace-unclosed.js | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/test/built-ins/RegExp/named-groups/string-replace-unclosed.js b/test/built-ins/RegExp/named-groups/string-replace-unclosed.js index 1952b8505..0cec59b21 100644 --- a/test/built-ins/RegExp/named-groups/string-replace-unclosed.js +++ b/test/built-ins/RegExp/named-groups/string-replace-unclosed.js @@ -2,25 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: SyntaxError is thrown for malformed replacements +description: A missing > following $< means that the $< is taken literally + in a replacement string in the context of named capture substitution. esid: sec-getsubstitution features: [regexp-named-groups] -info: > - Runtime Semantics: GetSubstitution( matched, str, position, captures, namedCaptures, replacement ) - - Table: Replacement Text Symbol Substitutions - - Unicode Characters: $< - Replacement text: - 2. Otherwise, - a. Scan until the next >, throwing a SyntaxError exception if one is not found, and let the enclosed substring be groupName. ---*/ let source = "(?<fst>.)(?<snd>.)|(?<thd>x)"; -for (let flags of ["", "u", "g", "gu"]) { +for (let flags of ["", "u"]) { + let re = new RegExp(source, flags); + assert.sameValue("$<sndcd", "abcd".replace(re, "$<snd")); +} +for (let flags of ["g", "gu"]) { let re = new RegExp(source, flags); - assert.throws(SyntaxError, () => "abcd".replace(re, "$<snd"), - "unclosed named group in replacement should throw a SyntaxError"); - assert.throws(SyntaxError, () => "abcd".replace(re, "$<>"), - "empty named group in replacement should throw a SyntaxError"); + assert.sameValue("$<snd$<snd", "abcd".replace(re, "$<snd")); } |