Skip to content

Commit b3bd888

Browse files
aplefullgmta
authored andcommitted
Tests+Meta: Reimport V8 regexp tests
This commit fixes assertEquals, assertThrows/assertDoesNotThrow in compatibility shim - we were failing some tests purely because of a bad shim. Two test files are moved from XFAIL_TESTS to SKIP_FILES: 1. es6/regexp-tostring.js: checks for V8-specific error message wording 2. es6/unicode-regexp-ignore-case-noi18n.js: tests V8's non-i18n build behavior, it doesn't case-fold non-ASCII characters, but we do it correctly. The regexp-unicode-sets.js test is now included and passes. All files that were previously in XFAIL_TESTS and SKIP_TESTS are now passing, so both lists are cleared.
1 parent c0a8dd4 commit b3bd888

62 files changed

Lines changed: 985 additions & 1343 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Meta/import-v8-regexp-tests.py

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
function assertEquals(expected, actual, msg) {
2020
if (Array.isArray(expected) && Array.isArray(actual)) {
2121
expect(actual).toEqual(expected);
22+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
23+
expect(actual.source).toBe(expected.source);
24+
expect(actual.flags).toBe(expected.flags);
2225
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
2326
expect(actual).toEqual(expected);
2427
} else {
@@ -43,11 +46,19 @@
4346
}
4447
4548
function assertThrows(fn, type_opt, msg_opt) {
46-
expect(fn).toThrow();
49+
if (typeof fn === "string") {
50+
expect(() => eval(fn)).toThrow();
51+
} else {
52+
expect(fn).toThrow();
53+
}
4754
}
4855
4956
function assertDoesNotThrow(fn, msg) {
50-
fn();
57+
if (typeof fn === "string") {
58+
eval(fn);
59+
} else {
60+
fn();
61+
}
5162
}
5263
5364
function assertInstanceof(val, type, msg) {
@@ -90,8 +101,11 @@
90101
# parse errors in other engines.
91102
"regexp-14098.js",
92103
"regexp-444637793.js",
93-
# Uses regex literal syntax that triggers parse errors in our engine.
94-
"regexp-unicode-sets.js",
104+
# Tests V8-specific error message wording ("incompatible receiver"), we correctly throw but use different message.
105+
"es6/regexp-tostring.js",
106+
# Tests V8's non-i18n build behavior. Spec-compliant engines (including ours) behave differently - we correctly
107+
# case-fold all cases.
108+
"es6/unicode-regexp-ignore-case-noi18n.js",
95109
# Multi-file dependency (lu-ui0..9 depend on testCodePointRange from lu-ui).
96110
"harmony/regexp-property-lu-ui0.js",
97111
"harmony/regexp-property-lu-ui1.js",
@@ -106,37 +120,11 @@
106120
}
107121

108122
# Tests that crash or hang -- use test.skip() so they don't block the suite.
109-
SKIP_TESTS = {
110-
# Hangs: catastrophic backtracking tests that rely on V8-specific
111-
# optimizations to terminate in reasonable time.
112-
"regexp-capture-3",
113-
# Crashes (SIGSEGV).
114-
"regexp-capture",
115-
}
123+
SKIP_TESTS = {}
116124

117125
# Tests that fail but should be tracked -- use test.xfail() so we notice
118126
# when they start passing.
119-
XFAIL_TESTS = {
120-
"es6/regexp-constructor",
121-
"es6/regexp-tostring",
122-
"es6/unicode-escapes-in-regexps",
123-
"es6/unicode-regexp-backrefs",
124-
"es6/unicode-regexp-ignore-case-noi18n",
125-
"es6/unicode-regexp-restricted-syntax",
126-
"es6/unicode-regexp-zero-length",
127-
"regexp-duplicate-named-groups",
128-
"regexp-lookahead",
129-
"regexp-multiline",
130-
"regexp-sort",
131-
"regexp-UC16",
132-
"harmony/regexp-property-binary",
133-
"harmony/regexp-property-char-class",
134-
"harmony/regexp-property-enumerated",
135-
"harmony/regexp-property-exact-match",
136-
"harmony/regexp-property-general-category",
137-
"harmony/regexp-property-invalid",
138-
"harmony/regexp-property-special",
139-
}
127+
XFAIL_TESTS = {}
140128

141129

142130
def should_skip(content):

Tests/LibJS/Runtime/3rdparty/v8/es6/array-concat-spreadable-regexp.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-constructor.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-flags.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-match-lastindex.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-prototype.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-replace-lastindex.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// V8 assertion compatibility shim for Ladybird's test-js harness
66

77
function assertEquals(expected, actual, msg) {
8-
if (expected instanceof RegExp && actual instanceof RegExp) {
8+
if (Array.isArray(expected) && Array.isArray(actual)) {
9+
expect(actual).toEqual(expected);
10+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
911
expect(actual.source).toBe(expected.source);
1012
expect(actual.flags).toBe(expected.flags);
11-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
12-
expect(actual).toEqual(expected);
1313
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
1414
expect(actual).toEqual(expected);
1515
} else {
@@ -35,17 +35,18 @@ function assertNotNull(val, msg) {
3535

3636
function assertThrows(fn, type_opt, msg_opt) {
3737
if (typeof fn === "string") {
38-
try {
39-
fn = new Function(fn);
40-
} catch (e) {
41-
return;
42-
}
38+
expect(() => eval(fn)).toThrow();
39+
} else {
40+
expect(fn).toThrow();
4341
}
44-
expect(fn).toThrow();
4542
}
4643

4744
function assertDoesNotThrow(fn, msg) {
48-
fn();
45+
if (typeof fn === "string") {
46+
eval(fn);
47+
} else {
48+
fn();
49+
}
4950
}
5051

5152
function assertInstanceof(val, type, msg) {

Tests/LibJS/Runtime/3rdparty/v8/es6/regexp-sticky.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
// V8 assertion compatibility shim for Ladybird's test-js harness
2929

3030
function assertEquals(expected, actual, msg) {
31-
if (expected instanceof RegExp && actual instanceof RegExp) {
31+
if (Array.isArray(expected) && Array.isArray(actual)) {
32+
expect(actual).toEqual(expected);
33+
} else if (expected instanceof RegExp && actual instanceof RegExp) {
3234
expect(actual.source).toBe(expected.source);
3335
expect(actual.flags).toBe(expected.flags);
34-
} else if (Array.isArray(expected) && Array.isArray(actual)) {
35-
expect(actual).toEqual(expected);
3636
} else if (expected !== null && typeof expected === "object" && actual !== null && typeof actual === "object") {
3737
expect(actual).toEqual(expected);
3838
} else {
@@ -58,17 +58,18 @@ function assertNotNull(val, msg) {
5858

5959
function assertThrows(fn, type_opt, msg_opt) {
6060
if (typeof fn === "string") {
61-
try {
62-
fn = new Function(fn);
63-
} catch (e) {
64-
return;
65-
}
61+
expect(() => eval(fn)).toThrow();
62+
} else {
63+
expect(fn).toThrow();
6664
}
67-
expect(fn).toThrow();
6865
}
6966

7067
function assertDoesNotThrow(fn, msg) {
71-
fn();
68+
if (typeof fn === "string") {
69+
eval(fn);
70+
} else {
71+
fn();
72+
}
7273
}
7374

7475
function assertInstanceof(val, type, msg) {

0 commit comments

Comments
 (0)