Skip to content
Snippets Groups Projects
Commit ca314476 authored by Leo Balter's avatar Leo Balter Committed by GitHub
Browse files

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
parent 74954bfa
No related branches found
No related tags found
No related merge requests found
Showing
with 48 additions and 17 deletions
// 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");
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Named groups can be used in conjunction with lookbehind description: Named groups can be used in conjunction with lookbehind
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups, regexp-lookbehind] features: [regexp-named-groups, regexp-lookbehind]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
description: > description: >
Named groups in Unicode RegExps have some syntax errors and some Named groups in Unicode RegExps have some syntax errors and some
compatibility escape fallback behavior. compatibility escape fallback behavior.
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups, regexp-lookbehind] features: [regexp-named-groups, regexp-lookbehind]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Basic matching cases with non-Unicode groups description: Basic matching cases with non-Unicode groups
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Exotic named group names in non-Unicode RegExps description: Exotic named group names in non-Unicode RegExps
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
...@@ -13,7 +13,7 @@ assert.throws(SyntaxError, () => eval('/(?<\\u{03C0}>a)/'), "\\u{} escapes allow ...@@ -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.\u03C0);
assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$); assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$);
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", /(?<_\u200C>a)/.exec("bab").groups._\u200C);
assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D); assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D);
assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ); assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ);
...@@ -30,7 +30,6 @@ assert.throws(SyntaxError, () => eval("/(?<a\\u{10FFFF}>.)/")); ...@@ -30,7 +30,6 @@ assert.throws(SyntaxError, () => eval("/(?<a\\u{10FFFF}>.)/"));
assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lea"); assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lea");
assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trai"); assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trai");
assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate"); assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate");
assert(RegExp("(?<a\u{104A4}>.)").test("a"), "Surrogate, ID_Continue");
// Bracketed escapes are not allowed; // Bracketed escapes are not allowed;
// 4-char escapes must be the proper ID_Start/ID_Continue // 4-char escapes must be the proper ID_Start/ID_Continue
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Named backreferences in non-Unicode RegExps description: Named backreferences in non-Unicode RegExps
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
......
...@@ -18,7 +18,7 @@ info: > ...@@ -18,7 +18,7 @@ info: >
// @@replace with a string replacement argument (no named captures). // @@replace with a string replacement argument (no named captures).
let source = "(.)(.)|(x)"; let source = "(.)(.)|(x)";
for (let flags of ["", "u", "g", "gu"]) { for (let flags of ["", "u"]) {
let re = new RegExp(source, flags); let re = new RegExp(source, flags);
assert.sameValue("$<snd>$<fst>cd", "abcd".replace(re, "$<snd>$<fst>")); assert.sameValue("$<snd>$<fst>cd", "abcd".replace(re, "$<snd>$<fst>"));
assert.sameValue("bacd", "abcd".replace(re, "$2$1")); assert.sameValue("bacd", "abcd".replace(re, "$2$1"));
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Various syntax errors for Unicode RegExps containing named groups description: Various syntax errors for Unicode RegExps containing named groups
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
---*/ ---*/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Basic matching cases with Unicode groups description: Basic matching cases with Unicode groups
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*--- /*---
description: Exotic named group names in Unicode RegExps description: Exotic named group names in Unicode RegExps
esid: pending esid: prod-GroupSpecifier
features: [regexp-named-groups] features: [regexp-named-groups]
---*/ ---*/
......
// Copyright (C) 2017 the V8 project authors. All rights reserved. // Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-get-regexp.prototype.flags esid: sec-get-regexp.prototype.flags
description: > description: >
...@@ -20,9 +21,5 @@ info: > ...@@ -20,9 +21,5 @@ info: >
features: [regexp-dotall] features: [regexp-dotall]
---*/ ---*/
assert.sameValue("gimsuy", new RegExp("", "gimsuy").flags); assert.sameValue(new RegExp("", "gimsuy").flags, "gimsuy", "gimsuy => gimsuy");
assert.sameValue("gimsuy", new RegExp("", "yusmig").flags); assert.sameValue(new RegExp("", "yusmig").flags, "gimsuy", "yusmig => gimsuy");
let re = /(?:)/;
re.compile("(?:)", "imsuyg");
assert.sameValue("gimsuy", re.flags);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment