From ca314476a99a3f17b2550b75ec66f0e3e1375c58 Mon Sep 17 00:00:00 2001
From: Leo Balter <leonardo.balter@gmail.com>
Date: Mon, 1 May 2017 12:08:31 -0400
Subject: [PATCH] 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
---
 .../prototype/flags/order-after-compile.js    | 35 +++++++++++++++++++
 .../RegExp/named-groups/lookbehind.js         |  2 +-
 .../named-groups/non-unicode-malformed.js     |  2 +-
 .../RegExp/named-groups/non-unicode-match.js  |  2 +-
 .../non-unicode-property-names.js             |  5 ++-
 .../named-groups/non-unicode-references.js    |  2 +-
 .../named-groups/string-replace-nocaptures.js |  2 +-
 .../RegExp/named-groups/unicode-malformed.js  |  2 +-
 .../RegExp/named-groups/unicode-match.js      |  2 +-
 .../named-groups/unicode-property-names.js    |  2 +-
 .../built-ins/RegExp/prototype/flags/order.js |  9 ++---
 11 files changed, 48 insertions(+), 17 deletions(-)
 create mode 100644 test/annexB/built-ins/RegExp/prototype/flags/order-after-compile.js

diff --git a/test/annexB/built-ins/RegExp/prototype/flags/order-after-compile.js b/test/annexB/built-ins/RegExp/prototype/flags/order-after-compile.js
new file mode 100644
index 0000000000..068b00d7bd
--- /dev/null
+++ b/test/annexB/built-ins/RegExp/prototype/flags/order-after-compile.js
@@ -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");
diff --git a/test/built-ins/RegExp/named-groups/lookbehind.js b/test/built-ins/RegExp/named-groups/lookbehind.js
index 0009bc5008..e3926bc97e 100644
--- a/test/built-ins/RegExp/named-groups/lookbehind.js
+++ b/test/built-ins/RegExp/named-groups/lookbehind.js
@@ -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]
 ---*/
diff --git a/test/built-ins/RegExp/named-groups/non-unicode-malformed.js b/test/built-ins/RegExp/named-groups/non-unicode-malformed.js
index 6a6d7bd9ec..993ff17616 100644
--- a/test/built-ins/RegExp/named-groups/non-unicode-malformed.js
+++ b/test/built-ins/RegExp/named-groups/non-unicode-malformed.js
@@ -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]
 ---*/
diff --git a/test/built-ins/RegExp/named-groups/non-unicode-match.js b/test/built-ins/RegExp/named-groups/non-unicode-match.js
index 4e29bb24a4..7904c75e43 100644
--- a/test/built-ins/RegExp/named-groups/non-unicode-match.js
+++ b/test/built-ins/RegExp/named-groups/non-unicode-match.js
@@ -3,7 +3,7 @@
 
 /*---
 description: Basic matching cases with non-Unicode groups
-esid: pending
+esid: prod-GroupSpecifier
 features: [regexp-named-groups]
 includes: [compareArray.js]
 ---*/
diff --git a/test/built-ins/RegExp/named-groups/non-unicode-property-names.js b/test/built-ins/RegExp/named-groups/non-unicode-property-names.js
index fea50314a4..9c02d0b517 100644
--- a/test/built-ins/RegExp/named-groups/non-unicode-property-names.js
+++ b/test/built-ins/RegExp/named-groups/non-unicode-property-names.js
@@ -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
diff --git a/test/built-ins/RegExp/named-groups/non-unicode-references.js b/test/built-ins/RegExp/named-groups/non-unicode-references.js
index bbf7a0fa5a..33d62a3f0a 100644
--- a/test/built-ins/RegExp/named-groups/non-unicode-references.js
+++ b/test/built-ins/RegExp/named-groups/non-unicode-references.js
@@ -3,7 +3,7 @@
 
 /*---
 description: Named backreferences in non-Unicode RegExps
-esid: pending
+esid: prod-GroupSpecifier
 features: [regexp-named-groups]
 includes: [compareArray.js]
 ---*/
diff --git a/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js b/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js
index 03fccdc87a..39a5887069 100644
--- a/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js
+++ b/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js
@@ -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"));
diff --git a/test/built-ins/RegExp/named-groups/unicode-malformed.js b/test/built-ins/RegExp/named-groups/unicode-malformed.js
index f0f08a8ed4..33a09a2689 100644
--- a/test/built-ins/RegExp/named-groups/unicode-malformed.js
+++ b/test/built-ins/RegExp/named-groups/unicode-malformed.js
@@ -3,7 +3,7 @@
 
 /*---
 description: Various syntax errors for Unicode RegExps containing named groups
-esid: pending
+esid: prod-GroupSpecifier
 features: [regexp-named-groups]
 ---*/
 
diff --git a/test/built-ins/RegExp/named-groups/unicode-match.js b/test/built-ins/RegExp/named-groups/unicode-match.js
index f840d4cfe2..a8e1059bdb 100644
--- a/test/built-ins/RegExp/named-groups/unicode-match.js
+++ b/test/built-ins/RegExp/named-groups/unicode-match.js
@@ -3,7 +3,7 @@
 
 /*---
 description: Basic matching cases with Unicode groups
-esid: pending
+esid: prod-GroupSpecifier
 features: [regexp-named-groups]
 includes: [compareArray.js]
 ---*/
diff --git a/test/built-ins/RegExp/named-groups/unicode-property-names.js b/test/built-ins/RegExp/named-groups/unicode-property-names.js
index 149322bb2d..24e4a6ade9 100644
--- a/test/built-ins/RegExp/named-groups/unicode-property-names.js
+++ b/test/built-ins/RegExp/named-groups/unicode-property-names.js
@@ -3,7 +3,7 @@
 
 /*---
 description: Exotic named group names in Unicode RegExps
-esid: pending
+esid: prod-GroupSpecifier
 features: [regexp-named-groups]
 ---*/
 
diff --git a/test/built-ins/RegExp/prototype/flags/order.js b/test/built-ins/RegExp/prototype/flags/order.js
index 141cf21342..004b538b4b 100644
--- a/test/built-ins/RegExp/prototype/flags/order.js
+++ b/test/built-ins/RegExp/prototype/flags/order.js
@@ -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");
-- 
GitLab