Skip to content

Commit d2dfb64

Browse files
minor test enhancements
1 parent 5405982 commit d2dfb64

File tree

3 files changed

+57
-51
lines changed

3 files changed

+57
-51
lines changed

assembly/__spec_tests__/generated.spec.ts

+39-16
Original file line numberDiff line numberDiff line change
@@ -1087,11 +1087,16 @@ it("line: 261 - matches ^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-
10871087
"From abcd Mon Sep 01 12:33:02 1997".substring(5, 9)
10881088
);
10891089
});
1090-
xit("line: 262 - requires triage", () => {});
1091-
xit("line: 263 - requires triage", () => {});
1092-
xit("line: 264 - requires triage", () => {});
1090+
xit("line: 262 - issues with repeated capture groups", () => {});
1091+
xit("line: 263 - issues with repeated capture groups", () => {});
1092+
it("line: 264 - matches ^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d against 'From abcd Sep 01 12:33:02 1997'", () => {
1093+
expectNotMatch(
1094+
"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d",
1095+
["From abcd Sep 01 12:33:02 1997"]
1096+
);
1097+
});
10931098
xit("line: 265 - test cases with CRs not supported yet!", () => {});
1094-
xit("line: 266 - requires triage", () => {});
1099+
xit("line: 266 - test cases with CRs not supported yet!", () => {});
10951100
xit("line: 267 - non capturing groups not supported", () => {});
10961101
xit("line: 268 - non capturing groups not supported", () => {});
10971102
xit("line: 269 - non capturing groups not supported", () => {});
@@ -1100,7 +1105,7 @@ xit("line: 271 - non capturing groups not supported", () => {});
11001105
xit("line: 272 - non capturing groups not supported", () => {});
11011106
xit("line: 273 - non capturing groups not supported", () => {});
11021107
xit("line: 274 - non capturing groups not supported", () => {});
1103-
xit("line: 281 - requires triage", () => {});
1108+
xit("line: 281 - test regex contains syntax not supported in JS", () => {});
11041109
xit("line: 282 - back references are not supported", () => {});
11051110
xit("line: 283 - back references are not supported", () => {});
11061111
xit("line: 284 - back references are not supported", () => {});
@@ -1109,7 +1114,7 @@ xit("line: 286 - non capturing groups not supported", () => {});
11091114
xit("line: 287 - non capturing groups not supported", () => {});
11101115
xit("line: 288 - non capturing groups not supported", () => {});
11111116
xit("line: 289 - non capturing groups not supported", () => {});
1112-
xit("line: 290 - requires triage", () => {});
1117+
xit("line: 290 - the test behaviour differs between PCRE and JS", () => {});
11131118
xit("line: 291 - lazy quantifiers are not supported", () => {});
11141119
xit("line: 292 - lazy quantifiers are not supported", () => {});
11151120
xit("line: 293 - lazy quantifiers are not supported", () => {});
@@ -1132,8 +1137,26 @@ xit("line: 1085 - back references are not supported", () => {});
11321137
xit("line: 1086 - test encoding issue", () => {});
11331138
xit("line: 1087 - requires triage", () => {});
11341139
xit("line: 1088 - requires triage", () => {});
1135-
xit("line: 1089 - requires triage", () => {});
1136-
xit("line: 1090 - requires triage", () => {});
1140+
it("line: 1089 - matches abc\\\x0def\\x00pqr\\x000xyz\\x0000AB against 'abc456 abc\\x0def\x00pqr\x000xyz\x0000ABCDE'", () => {
1141+
const match = exec(
1142+
"abc\\\x0def\\x00pqr\\x000xyz\\x0000AB",
1143+
"abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE",
1144+
""
1145+
);
1146+
expect(match.matches[0]).toBe(
1147+
"abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE".substring(7, 27)
1148+
);
1149+
});
1150+
it("line: 1090 - matches abc\\\x0def\\x00pqr\\x000xyz\\x0000AB against 'abc456 abc\\x0def\x00pqr\x000xyz\x0000ABCDE'", () => {
1151+
const match = exec(
1152+
"abc\\\x0def\\x00pqr\\x000xyz\\x0000AB",
1153+
"abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE",
1154+
""
1155+
);
1156+
expect(match.matches[0]).toBe(
1157+
"abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE".substring(7, 27)
1158+
);
1159+
});
11371160
xit("line: 1091 - back references are not supported", () => {});
11381161
xit("line: 1092 - back references are not supported", () => {});
11391162
xit("line: 1093 - back references are not supported", () => {});
@@ -1145,7 +1168,7 @@ xit("line 1098 - issue with parsing the test itself", () => {});
11451168
xit("line: 1099 - back references are not supported", () => {});
11461169
xit("line: 1100 - back references are not supported", () => {});
11471170
xit("line: 1101 - back references are not supported", () => {});
1148-
xit("line: 1102 - bug that needs filing", () => {});
1171+
xit("line: 1102 - test contains an octal escape sequence", () => {});
11491172
xit("line 1103 - issue with parsing the test itself", () => {});
11501173
it("line: 1104 - matches ^\\s against '\\x0cxyz'", () => {
11511174
const match = exec("^\\s", "\x0cxyz", "");
@@ -1156,10 +1179,7 @@ it("line: 1105 - matches ^\\s against '\\fabc'", () => {
11561179
expect(match.matches[0]).toBe("\fabc".substring(0, 1));
11571180
});
11581181
xit("line: 1106 - test cases with CRs not supported yet!", () => {});
1159-
it("line: 1107 - matches ^\\s against '\\rabc'", () => {
1160-
const match = exec("^\\s", "\rabc", "");
1161-
expect(match.matches[0]).toBe("\rabc".substring(0, 1));
1162-
});
1182+
xit("line: 1107 - test cases with CRs not supported yet!", () => {});
11631183
it("line: 1108 - matches ^\\s against '\\tabc'", () => {
11641184
const match = exec("^\\s", "\tabc", "");
11651185
expect(match.matches[0]).toBe("\tabc".substring(0, 1));
@@ -1347,7 +1367,7 @@ xit("line 1186 - issue with parsing the test itself", () => {});
13471367
xit("line 1187 - issue with parsing the test itself", () => {});
13481368
xit("line 1188 - issue with parsing the test itself", () => {});
13491369
xit("line: 1189 - test indicates a malformed regex, whereas it appears OK in JS", () => {});
1350-
xit("line: 1190 - requires triage", () => {});
1370+
xit("line: 1190 - test cases with CRs not supported yet!", () => {});
13511371
xit("line: 1191 - test cases with CRs not supported yet!", () => {});
13521372
it("line: 1192 - matches abc$ against 'abc'", () => {
13531373
const match = exec("abc$", "abc", "");
@@ -1386,7 +1406,10 @@ it("line: 1223 - matches ab\\gdef against 'abgdef'", () => {
13861406
const match = exec("ab\\gdef", "abgdef", "");
13871407
expect(match.matches[0]).toBe("abgdef".substring(0, 6));
13881408
});
1389-
xit("line: 1224 - requires triage", () => {});
1409+
it("line: 1224 - matches a{0}bc against 'bc'", () => {
1410+
const match = exec("a{0}bc", "bc", "");
1411+
expect(match.matches[0]).toBe("bc".substring(0, 2));
1412+
});
13901413
xit("line: 1225 - lazy quantifiers are not supported", () => {});
13911414
xit("line: 1226 - back references are not supported", () => {});
13921415
xit("line: 1227 - back references are not supported", () => {});
@@ -1904,7 +1927,7 @@ xit("line: 1408 - test cases with quotes are not supported yet!", () => {});
19041927
xit("line: 1409 - lazy quantifiers are not supported", () => {});
19051928
xit("line: 1410 - word boundary class not supported yet!", () => {});
19061929
xit("line: 1411 - word boundary class not supported yet!", () => {});
1907-
xit("line: 1412 - requires triage", () => {});
1930+
xit("line: 1412 - test cases for NULL regexes not supported yet", () => {});
19081931
xit("line: 1413 - requires triage", () => {});
19091932
it("line: 1414 - matches a[^a]b against 'acb'", () => {
19101933
const match = exec("a[^a]b", "acb", "");

spec/test-generator.js

+16-33
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,26 @@ const knownIssues = {
1414
...range(1185, 1188),
1515
...range(1095, 1098),
1616
],
17-
"issues with repeated capture groups": [...range(63, 68), 1391, 1392],
18-
"bug that needs filing": [1102],
19-
"requires triage": [
17+
"issues with repeated capture groups": [
2018
262,
21-
281,
22-
264,
2319
263,
24-
265,
25-
266,
26-
1238,
27-
...range(289, 291),
28-
1224,
29-
1277,
30-
1278,
31-
1373,
32-
1376,
33-
1412,
20+
...range(63, 68),
21+
1391,
22+
1392,
23+
],
24+
"test contains an octal escape sequence": [1102],
25+
"requires triage": [
3426
1087,
3527
1088,
36-
1348,
37-
1349,
38-
...range(1351, 1359),
39-
1360,
40-
1361,
41-
1363,
42-
1367,
43-
1369,
44-
1308,
45-
1237,
46-
1190,
4728
1239,
48-
1089,
49-
1090,
5029
...range(1147, 1149),
51-
...range(1408, 1410),
5230
1413,
53-
...range(1301, 1307),
31+
...range(1301, 1308),
5432
],
5533
"as-pect test issue": [1145, 1146],
5634
"test indicates a malformed regex, whereas it appears OK in JS": [1189],
57-
"test regex contains syntax not supported in JS": [82, 1158],
58-
"test doesn't support NULL": [1411],
35+
"test regex contains syntax not supported in JS": [82, 1158, 281],
36+
"the test behaviour differs between PCRE and JS": [290],
5937
"aspect [Actual]: <Match>null vs [Expected]: Not <Match>null issue": [
6038
153,
6139
203,
@@ -110,12 +88,17 @@ lines.forEach((line, index) => {
11088
return;
11189
}
11290

91+
if (regex == "NULL") {
92+
testCase += `xit("line: ${index} - test cases for NULL regexes not supported yet", () => { });`;
93+
return;
94+
}
95+
11396
if (regex.includes("\\b")) {
11497
testCase += `xit("line: ${index} - word boundary class not supported yet!", () => { });`;
11598
return;
11699
}
117100

118-
if (str.includes("\\n")) {
101+
if (str.includes("\\n") || str.includes("\\r")) {
119102
testCase += `xit("line: ${index} - test cases with CRs not supported yet!", () => { });`;
120103
return;
121104
}

ts/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ globalAny.log = console.log;
55

66
import { RegExp } from "../assembly/regexp";
77

8-
const regexObj = new RegExp("a{3}{2}");
9-
const match = regexObj.exec("From abcd Mon Sep 01 12:33:02 1997");
8+
const regexObj = new RegExp("^\\s");
9+
const match = regexObj.exec("\040abc");
1010

1111
console.log(match);

0 commit comments

Comments
 (0)