Update RegExp tests for named-capturing and dotAll (#1009)

* Split order tests for RegExp#flags

* small fixes for RegExp named groups

* Remove invalid syntax

* The test mustn't include the global flag
This commit is contained in:
Leo Balter 2017-05-01 12:08:31 -04:00 committed by GitHub
parent 74954bfa91
commit ca314476a9
11 changed files with 48 additions and 17 deletions

View File

@ -0,0 +1,35 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-regexp.prototype.flags
description: >
The flags come in the same order in a new instance produced by RegExp.prototype.compile
info: |
B.2.5.1 RegExp.prototype.compile ( pattern, flags )
...
5. Return ? RegExpInitialize(O, P, F).
21.2.5.3 get RegExp.prototype.flags
...
4. Let global be ToBoolean(? Get(R, "global")).
5. If global is true, append "g" as the last code unit of result.
6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
7. If ignoreCase is true, append "i" as the last code unit of result.
8. Let multiline be ToBoolean(? Get(R, "multiline")).
9. If multiline is true, append "m" as the last code unit of result.
10. Let dotAll be ToBoolean(? Get(R, "dotAll")).
11. If dotAll is true, append "s" as the last code unit of result.
12. Let unicode be ToBoolean(? Get(R, "unicode")).
13. If unicode is true, append "u" as the last code unit of result.
14. Let sticky be ToBoolean(? Get(R, "sticky")).
15. If sticky is true, append "y" as the last code unit of result.
14. Return result.
features: [regexp-dotall]
---*/
let re = /(?:)/;
re.compile("(?:)", "imsuyg");
assert.sameValue(re.flags, "gimsuy");

View File

@ -3,7 +3,7 @@
/*---
description: Named groups can be used in conjunction with lookbehind
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups, regexp-lookbehind]
includes: [compareArray.js]
---*/

View File

@ -5,7 +5,7 @@
description: >
Named groups in Unicode RegExps have some syntax errors and some
compatibility escape fallback behavior.
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups, regexp-lookbehind]
includes: [compareArray.js]
---*/

View File

@ -3,7 +3,7 @@
/*---
description: Basic matching cases with non-Unicode groups
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
includes: [compareArray.js]
---*/

View File

@ -3,7 +3,7 @@
/*---
description: Exotic named group names in non-Unicode RegExps
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
includes: [compareArray.js]
---*/
@ -13,7 +13,7 @@ assert.throws(SyntaxError, () => eval('/(?<\\u{03C0}>a)/'), "\\u{} escapes allow
assert.sameValue("a", /(?<π>a)/.exec("bab").groups.\u03C0);
assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$);
assert.sameValue("a", /(?<_>a)/.exec("bab").groups._);
assert.throws(SyntaxError, () => eval('/(?<$𐒤>a)/'), "Individual surrogates not in ID_Continue);
assert.throws(SyntaxError, () => eval('/(?<$𐒤>a)/'), "Individual surrogates not in ID_Continue");
assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\u200C);
assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D);
assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups._ಠ);
@ -30,7 +30,6 @@ assert.throws(SyntaxError, () => eval("/(?<a\\u{10FFFF}>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lea");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trai");
assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate");
assert(RegExp("(?<a\u{104A4}>.)").test("a"), "Surrogate, ID_Continue");
// Bracketed escapes are not allowed;
// 4-char escapes must be the proper ID_Start/ID_Continue

View File

@ -3,7 +3,7 @@
/*---
description: Named backreferences in non-Unicode RegExps
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
includes: [compareArray.js]
---*/

View File

@ -18,7 +18,7 @@ info: >
// @@replace with a string replacement argument (no named captures).
let source = "(.)(.)|(x)";
for (let flags of ["", "u", "g", "gu"]) {
for (let flags of ["", "u"]) {
let re = new RegExp(source, flags);
assert.sameValue("$<snd>$<fst>cd", "abcd".replace(re, "$<snd>$<fst>"));
assert.sameValue("bacd", "abcd".replace(re, "$2$1"));

View File

@ -3,7 +3,7 @@
/*---
description: Various syntax errors for Unicode RegExps containing named groups
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
---*/

View File

@ -3,7 +3,7 @@
/*---
description: Basic matching cases with Unicode groups
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
includes: [compareArray.js]
---*/

View File

@ -3,7 +3,7 @@
/*---
description: Exotic named group names in Unicode RegExps
esid: pending
esid: prod-GroupSpecifier
features: [regexp-named-groups]
---*/

View File

@ -1,5 +1,6 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-regexp.prototype.flags
description: >
@ -20,9 +21,5 @@ info: >
features: [regexp-dotall]
---*/
assert.sameValue("gimsuy", new RegExp("", "gimsuy").flags);
assert.sameValue("gimsuy", new RegExp("", "yusmig").flags);
let re = /(?:)/;
re.compile("(?:)", "imsuyg");
assert.sameValue("gimsuy", re.flags);
assert.sameValue(new RegExp("", "gimsuy").flags, "gimsuy", "gimsuy => gimsuy");
assert.sameValue(new RegExp("", "yusmig").flags, "gimsuy", "yusmig => gimsuy");