Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import and modernize bocoup/test262-regexp-generator #4303

Merged
merged 14 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[{README.md,package.json,*.yml,*.sh,*.js,*.case,*.template}]
[{README.md,package.json,*.yml,*.sh,*.js,*.mjs,*.case,*.template}]
indent_style = space
indent_size = 2

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
python -m pip install --upgrade pip
pip install -r tools/generation/requirements.txt

- name: Install dependencies for regexp-generator tool
run: |
cd tools/regexp-generator
npm install

- name: Build tests
run: |
./make.py clean >/dev/null
Expand Down
18 changes: 15 additions & 3 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
OUT_DIR = os.environ.get('OUT_DIR') or 'test'
SRC_DIR = os.environ.get('SRC_DIR') or 'src'

def shell(*args):
sp = subprocess.Popen(list(args), stdout=subprocess.PIPE, universal_newlines=True)

def shell(*args, **kwargs):
sp = subprocess.Popen(list(args), stdout=subprocess.PIPE,
universal_newlines=True, **kwargs)
cmd_str = ' '.join(args)

print('> ' + cmd_str)
Expand All @@ -36,17 +38,27 @@ def wrapped():
return wrapped
return other


@target()
def npm_deps():
shell('npm', 'install', cwd='./tools/regexp-generator')


@target('npm_deps')
def build():
shell(sys.executable, 'tools/generation/generator.py',
'create',
'--parents',
'--out', OUT_DIR,
SRC_DIR)
shell('npm', 'run', 'build', cwd='./tools/regexp-generator')

@target()

@target('npm_deps')
def clean():
shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR)
shell('npm', 'run', 'clean', cwd='./tools/regexp-generator')


if len(sys.argv) == 1:
targets['build']()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,51 @@
/*---
esid: prod-CharacterClassEscape
description: >
Compare range for digit class escape \d with flags ug
Compare range for digit class escape \d with flags ug
info: |
This is a generated test. Please check out
https://github.com/bocoup/test262-regexp-generator
for any changes.
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
for any changes.

CharacterClassEscape[U] ::
d
D
s
S
w
W
CharacterClassEscape[UnicodeMode] ::
d
D
s
S
w
W
[+UnicodeMode] p{ UnicodePropertyValueExpression }
[+UnicodeMode] P{ UnicodePropertyValueExpression }

21.2.2.12 CharacterClassEscape
22.2.2.9 Runtime Semantics: CompileToCharSet

The production CharacterClassEscape :: d evaluates as follows:
Return the ten-element set of characters containing the characters 0 through 9 inclusive.
The production CharacterClassEscape :: D evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: d.
The production CharacterClassEscape :: s evaluates as follows:
Return the set of characters containing the characters that are on the right-hand side of
the WhiteSpace or LineTerminator productions.
The production CharacterClassEscape :: S evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: s.
The production CharacterClassEscape :: w evaluates as follows:
Return the set of all characters returned by WordCharacters().
The production CharacterClassEscape :: W evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: w.
CharacterClassEscape :: d
1. Return the ten-element CharSet containing the characters 0, 1, 2, 3, 4,
5, 6, 7, 8, and 9.
CharacterClassEscape :: D
1. Let S be the CharSet returned by CharacterClassEscape :: d.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: s
1. Return the CharSet containing all characters corresponding to a code
point on the right-hand side of the WhiteSpace or LineTerminator
productions.
CharacterClassEscape :: S
1. Let S be the CharSet returned by CharacterClassEscape :: s.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: w
1. Return MaybeSimpleCaseFolding(rer, WordCharacters(rer)).
CharacterClassEscape :: W
1. Let S be the CharSet returned by CharacterClassEscape :: w.
2. Return CharacterComplement(rer, S).
features: [String.fromCodePoint]
includes: [regExpUtils.js]
flags: [generated]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x0030, 0x0039],
[0x000030, 0x000039],
],
});

Expand All @@ -49,16 +57,16 @@ const re = /\d/ug;
const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
}
}

assert.sameValue(
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,51 @@
/*---
esid: prod-CharacterClassEscape
description: >
Compare range for digit class escape \d+ with flags ug
Compare range for digit class escape \d+ with flags ug
info: |
This is a generated test. Please check out
https://github.com/bocoup/test262-regexp-generator
for any changes.
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
for any changes.

CharacterClassEscape[U] ::
d
D
s
S
w
W
CharacterClassEscape[UnicodeMode] ::
d
D
s
S
w
W
[+UnicodeMode] p{ UnicodePropertyValueExpression }
[+UnicodeMode] P{ UnicodePropertyValueExpression }

21.2.2.12 CharacterClassEscape
22.2.2.9 Runtime Semantics: CompileToCharSet

The production CharacterClassEscape :: d evaluates as follows:
Return the ten-element set of characters containing the characters 0 through 9 inclusive.
The production CharacterClassEscape :: D evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: d.
The production CharacterClassEscape :: s evaluates as follows:
Return the set of characters containing the characters that are on the right-hand side of
the WhiteSpace or LineTerminator productions.
The production CharacterClassEscape :: S evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: s.
The production CharacterClassEscape :: w evaluates as follows:
Return the set of all characters returned by WordCharacters().
The production CharacterClassEscape :: W evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: w.
CharacterClassEscape :: d
1. Return the ten-element CharSet containing the characters 0, 1, 2, 3, 4,
5, 6, 7, 8, and 9.
CharacterClassEscape :: D
1. Let S be the CharSet returned by CharacterClassEscape :: d.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: s
1. Return the CharSet containing all characters corresponding to a code
point on the right-hand side of the WhiteSpace or LineTerminator
productions.
CharacterClassEscape :: S
1. Let S be the CharSet returned by CharacterClassEscape :: s.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: w
1. Return MaybeSimpleCaseFolding(rer, WordCharacters(rer)).
CharacterClassEscape :: W
1. Let S be the CharSet returned by CharacterClassEscape :: w.
2. Return CharacterComplement(rer, S).
features: [String.fromCodePoint]
includes: [regExpUtils.js]
flags: [generated]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x0030, 0x0039],
[0x000030, 0x000039],
],
});

Expand All @@ -49,16 +57,16 @@ const re = /\d+/ug;
const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
}
}

assert.sameValue(
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,51 @@
/*---
esid: prod-CharacterClassEscape
description: >
Compare range for digit class escape \d+ with flags g
Compare range for digit class escape \d+ with flags g
info: |
This is a generated test. Please check out
https://github.com/bocoup/test262-regexp-generator
for any changes.
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
for any changes.

CharacterClassEscape[U] ::
d
D
s
S
w
W
CharacterClassEscape[UnicodeMode] ::
d
D
s
S
w
W
[+UnicodeMode] p{ UnicodePropertyValueExpression }
[+UnicodeMode] P{ UnicodePropertyValueExpression }

21.2.2.12 CharacterClassEscape
22.2.2.9 Runtime Semantics: CompileToCharSet

The production CharacterClassEscape :: d evaluates as follows:
Return the ten-element set of characters containing the characters 0 through 9 inclusive.
The production CharacterClassEscape :: D evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: d.
The production CharacterClassEscape :: s evaluates as follows:
Return the set of characters containing the characters that are on the right-hand side of
the WhiteSpace or LineTerminator productions.
The production CharacterClassEscape :: S evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: s.
The production CharacterClassEscape :: w evaluates as follows:
Return the set of all characters returned by WordCharacters().
The production CharacterClassEscape :: W evaluates as follows:
Return the set of all characters not included in the set returned by CharacterClassEscape :: w.
CharacterClassEscape :: d
1. Return the ten-element CharSet containing the characters 0, 1, 2, 3, 4,
5, 6, 7, 8, and 9.
CharacterClassEscape :: D
1. Let S be the CharSet returned by CharacterClassEscape :: d.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: s
1. Return the CharSet containing all characters corresponding to a code
point on the right-hand side of the WhiteSpace or LineTerminator
productions.
CharacterClassEscape :: S
1. Let S be the CharSet returned by CharacterClassEscape :: s.
2. Return CharacterComplement(rer, S).
CharacterClassEscape :: w
1. Return MaybeSimpleCaseFolding(rer, WordCharacters(rer)).
CharacterClassEscape :: W
1. Let S be the CharSet returned by CharacterClassEscape :: w.
2. Return CharacterComplement(rer, S).
features: [String.fromCodePoint]
includes: [regExpUtils.js]
flags: [generated]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x0030, 0x0039],
[0x000030, 0x000039],
],
});

Expand All @@ -49,16 +57,16 @@ const re = /\d+/g;
const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
}
}

assert.sameValue(
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
errors.length,
0,
'Expected matching code points, but received: ' + errors.join(',')
);
Loading
Loading