From f9a0f05850f2d8a3f5778282f71962285235d3d4 Mon Sep 17 00:00:00 2001
From: Daniel Ehrenberg <littledan@chromium.org>
Date: Mon, 26 Feb 2018 12:26:38 +0100
Subject: [PATCH] Additional tests for QuantifiableAssertion

- Tests that lookahead and lookbehind are not extended to
  QuantifiableAssertion, as in https://github.com/tc39/ecma262/pull/1102
- Additional tests verifying some more combinations of cases for
  QuantifiableAssertion being invalid in Unicode mode.

Based on the tests in https://chromium-review.googlesource.com/c/v8/v8/+/926102

These tests pass on V8 (if the throw for early errors is removed to
work around a V8 issue where RegExps don't have early errors).
---
 .../regexp/invalid-optional-lookbehind.js     | 20 +++++++++++++++++++
 .../invalid-optional-negative-lookbehind.js   | 20 +++++++++++++++++++
 .../regexp/invalid-range-lookbehind.js        | 20 +++++++++++++++++++
 .../invalid-range-negative-lookbehind.js      | 20 +++++++++++++++++++
 ...ion.js => u-invalid-optional-lookahead.js} |  0
 .../regexp/u-invalid-optional-lookbehind.js   | 20 +++++++++++++++++++
 .../u-invalid-optional-negative-lookahead.js  | 20 +++++++++++++++++++
 .../u-invalid-optional-negative-lookbehind.js | 20 +++++++++++++++++++
 .../regexp/u-invalid-range-lookahead.js       | 20 +++++++++++++++++++
 .../regexp/u-invalid-range-lookbehind.js      | 20 +++++++++++++++++++
 .../u-invalid-range-negative-lookahead.js     | 20 +++++++++++++++++++
 .../u-invalid-range-negative-lookbehind.js    | 20 +++++++++++++++++++
 12 files changed, 220 insertions(+)
 create mode 100644 test/language/literals/regexp/invalid-optional-lookbehind.js
 create mode 100644 test/language/literals/regexp/invalid-optional-negative-lookbehind.js
 create mode 100644 test/language/literals/regexp/invalid-range-lookbehind.js
 create mode 100644 test/language/literals/regexp/invalid-range-negative-lookbehind.js
 rename test/language/literals/regexp/{u-invalid-quantifiable-assertion.js => u-invalid-optional-lookahead.js} (100%)
 create mode 100644 test/language/literals/regexp/u-invalid-optional-lookbehind.js
 create mode 100644 test/language/literals/regexp/u-invalid-optional-negative-lookahead.js
 create mode 100644 test/language/literals/regexp/u-invalid-optional-negative-lookbehind.js
 create mode 100644 test/language/literals/regexp/u-invalid-range-lookahead.js
 create mode 100644 test/language/literals/regexp/u-invalid-range-lookbehind.js
 create mode 100644 test/language/literals/regexp/u-invalid-range-negative-lookahead.js
 create mode 100644 test/language/literals/regexp/u-invalid-range-negative-lookbehind.js

diff --git a/test/language/literals/regexp/invalid-optional-lookbehind.js b/test/language/literals/regexp/invalid-optional-lookbehind.js
new file mode 100644
index 0000000000..0e46d6b251
--- /dev/null
+++ b/test/language/literals/regexp/invalid-optional-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<=.)?/;
diff --git a/test/language/literals/regexp/invalid-optional-negative-lookbehind.js b/test/language/literals/regexp/invalid-optional-negative-lookbehind.js
new file mode 100644
index 0000000000..b972bc6764
--- /dev/null
+++ b/test/language/literals/regexp/invalid-optional-negative-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<!.)?/;
diff --git a/test/language/literals/regexp/invalid-range-lookbehind.js b/test/language/literals/regexp/invalid-range-lookbehind.js
new file mode 100644
index 0000000000..2019433e82
--- /dev/null
+++ b/test/language/literals/regexp/invalid-range-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<=.){2,3}/;
diff --git a/test/language/literals/regexp/invalid-range-negative-lookbehind.js b/test/language/literals/regexp/invalid-range-negative-lookbehind.js
new file mode 100644
index 0000000000..c02122bbb1
--- /dev/null
+++ b/test/language/literals/regexp/invalid-range-negative-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<!.){2,3}/;
diff --git a/test/language/literals/regexp/u-invalid-quantifiable-assertion.js b/test/language/literals/regexp/u-invalid-optional-lookahead.js
similarity index 100%
rename from test/language/literals/regexp/u-invalid-quantifiable-assertion.js
rename to test/language/literals/regexp/u-invalid-optional-lookahead.js
diff --git a/test/language/literals/regexp/u-invalid-optional-lookbehind.js b/test/language/literals/regexp/u-invalid-optional-lookbehind.js
new file mode 100644
index 0000000000..d36b4e0c9d
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-optional-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<=.)?/u;
diff --git a/test/language/literals/regexp/u-invalid-optional-negative-lookahead.js b/test/language/literals/regexp/u-invalid-optional-negative-lookahead.js
new file mode 100644
index 0000000000..e12dcae6e6
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-optional-negative-lookahead.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+es6id: B.1.4
+description: Quantifiable assertions disallowed with `u` flag
+info: |
+    The `u` flag precludes quantifiable assertions (even when Annex B is
+    honored)
+
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?!.)?/u;
diff --git a/test/language/literals/regexp/u-invalid-optional-negative-lookbehind.js b/test/language/literals/regexp/u-invalid-optional-negative-lookbehind.js
new file mode 100644
index 0000000000..6697fa05fa
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-optional-negative-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<!.)?/u;
diff --git a/test/language/literals/regexp/u-invalid-range-lookahead.js b/test/language/literals/regexp/u-invalid-range-lookahead.js
new file mode 100644
index 0000000000..1c6efb12c7
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-range-lookahead.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+es6id: B.1.4
+description: Quantifiable assertions disallowed with `u` flag
+info: |
+    The `u` flag precludes quantifiable assertions (even when Annex B is
+    honored)
+
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?=.){2,3}/u;
diff --git a/test/language/literals/regexp/u-invalid-range-lookbehind.js b/test/language/literals/regexp/u-invalid-range-lookbehind.js
new file mode 100644
index 0000000000..a690848698
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-range-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<=.){2,3}/u;
diff --git a/test/language/literals/regexp/u-invalid-range-negative-lookahead.js b/test/language/literals/regexp/u-invalid-range-negative-lookahead.js
new file mode 100644
index 0000000000..18d3c1b126
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-range-negative-lookahead.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+es6id: B.1.4
+description: Quantifiable assertions disallowed with `u` flag
+info: |
+    The `u` flag precludes quantifiable assertions (even when Annex B is
+    honored)
+
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?!.){2,3}/u;
diff --git a/test/language/literals/regexp/u-invalid-range-negative-lookbehind.js b/test/language/literals/regexp/u-invalid-range-negative-lookbehind.js
new file mode 100644
index 0000000000..7bb80a2499
--- /dev/null
+++ b/test/language/literals/regexp/u-invalid-range-negative-lookbehind.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Igalia S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-regular-expressions-patterns
+description: Lookbehinds are not treated as a QuantifiableAssertion
+info: |
+    Term[U] ::
+         [~U] QuantifiableAssertion Quantifier
+
+    QuantifiableAssertion[N]::
+        ( ? = Disjunction[~U, ?N] )
+        ( ? ! Disjunction[~U, ?N] )
+negative:
+  phase: parse
+  type: SyntaxError
+---*/
+
+throw "Test262: This statement should not be evaluated.";
+
+/.(?<!.){2,3}/u;
-- 
GitLab