Skip to content

Commit

Permalink
Adds syntax tests for the RegExp modifiers proposal
Browse files Browse the repository at this point in the history
Based on PR tc39#3807 which had generated these tests from templates,
but was stuck due to issue tc39#3808.

Co-Authored-By: Guillaume Emont <[email protected]>
Co-Authored-By: Ioanna M. Dimitriou H <[email protected]>
  • Loading branch information
3 people authored and ptomato committed Mar 5, 2024
1 parent f4f84ce commit 356188a
Show file tree
Hide file tree
Showing 151 changed files with 2,539 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?ii:a)", "");
}, 'RegExp("(?ii:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?imsi:a)", "");
}, 'RegExp("(?imsi:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?1:a)", "");
}, 'RegExp("(?1:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?iͥ:a)", "");
}, 'RegExp("(?iͥ:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?mͫ:a)", "");
}, 'RegExp("(?mͫ:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?s̀:a)", "");
}, 'RegExp("(?s̀:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?d:a)", "");
}, 'RegExp("(?d:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-g.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?g:a)", "");
}, 'RegExp("(?g:a)", ""): ');
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?s‎:a)", "");
}, 'RegExp("(?s‎:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?Q:a)", "");
}, 'RegExp("(?Q:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-u.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?u:a)", "");
}, 'RegExp("(?u:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?y:a)", "");
}, 'RegExp("(?y:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?s‍:a)", "");
}, 'RegExp("(?s‍:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?s:a)", "");
}, 'RegExp("(?s:a)", ""): ');
16 changes: 16 additions & 0 deletions test/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?s‌:a)", "");
}, 'RegExp("(?s‌:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?I:a)", "i");
}, 'RegExp("(?I:a)", "i"): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?M:a)", "i");
}, 'RegExp("(?M:a)", "i"): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?S:a)", "i");
}, 'RegExp("(?S:a)", "i"): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?İ:a)", "iu");
}, 'RegExp("(?İ:a)", "iu"): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpresisonFlags : Disjunction )
It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once.
---*/

assert.throws(SyntaxError, function () {
RegExp("(?ſ:a)", "u");
}, 'RegExp("(?ſ:a)", "u"): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction )
...
---*/

assert.throws(SyntaxError, function () {
RegExp("(?i-i:a)", "");
}, 'RegExp("(?i-i:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction )
...
---*/

assert.throws(SyntaxError, function () {
RegExp("(?m-m:a)", "");
}, 'RegExp("(?m-m:a)", ""): ');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags)
esid: sec-patterns-static-semantics-early-errors
features: [regexp-modifiers]
info: |
Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction )
...
---*/

assert.throws(SyntaxError, function () {
RegExp("(?ims-m:a)", "");
}, 'RegExp("(?ims-m:a)", ""): ');
Loading

0 comments on commit 356188a

Please sign in to comment.