Skip to content

Commit c0b2431

Browse files
committed
Tests for ECMA 262 regex dialect
1 parent b6f79ee commit c0b2431

File tree

4 files changed

+724
-0
lines changed

4 files changed

+724
-0
lines changed

tests/draft2019-09/optional/ecmascript-regex.json

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,186 @@
99
"valid": false
1010
}
1111
]
12+
},
13+
{
14+
"description": "ECMA 262 regex converts \\a to ascii BEL",
15+
"schema": {
16+
"type": "string",
17+
"pattern": "^\\a$"
18+
},
19+
"tests": [
20+
{
21+
"description": "does not match",
22+
"data": "\\a",
23+
"valid": false
24+
},
25+
{
26+
"description": "matches",
27+
"data": "\u0007",
28+
"valid": true
29+
}
30+
]
31+
},
32+
{
33+
"description": "ECMA 262 regex escapes control codes with \\c and upper letter",
34+
"schema": {
35+
"type": "string",
36+
"pattern": "^\\cC$"
37+
},
38+
"tests": [
39+
{
40+
"description": "does not match",
41+
"data": "\\cC",
42+
"valid": false
43+
},
44+
{
45+
"description": "matches",
46+
"data": "\u0003",
47+
"valid": true
48+
}
49+
]
50+
},
51+
{
52+
"description": "ECMA 262 regex escapes control codes with \\c and lower letter",
53+
"schema": {
54+
"type": "string",
55+
"pattern": "^\\cc$"
56+
},
57+
"tests": [
58+
{
59+
"description": "does not match",
60+
"data": "\\cc",
61+
"valid": false
62+
},
63+
{
64+
"description": "matches",
65+
"data": "\u0003",
66+
"valid": true
67+
}
68+
]
69+
},
70+
{
71+
"description": "ECMA 262 \\d matches ascii digits only",
72+
"schema": {
73+
"type": "string",
74+
"pattern": "^\\d$"
75+
},
76+
"tests": [
77+
{
78+
"description": "ASCII zero matches",
79+
"data": "0",
80+
"valid": true
81+
},
82+
{
83+
"description": "NKO DIGIT ZERO does not match (unlike e.g. Python)",
84+
"data": "߀",
85+
"valid": false
86+
},
87+
{
88+
"description": "NKO DIGIT ZERO (as \\u escape) does not match",
89+
"data": "\\u07c0",
90+
"valid": false
91+
}
92+
]
93+
},
94+
{
95+
"description": "ECMA 262 \\D matches everything but ascii digits",
96+
"schema": {
97+
"type": "string",
98+
"pattern": "^\\D$"
99+
},
100+
"tests": [
101+
{
102+
"description": "ASCII zero does not match",
103+
"data": "0",
104+
"valid": false
105+
},
106+
{
107+
"description": "NKO DIGIT ZERO matches (unlike e.g. Python)",
108+
"data": "߀",
109+
"valid": true
110+
},
111+
{
112+
"description": "NKO DIGIT ZERO (as \\u escape) matches",
113+
"data": "\\u07c0",
114+
"valid": true
115+
}
116+
]
117+
},
118+
{
119+
"description": "ECMA 262 \\w matches ascii letters only",
120+
"schema": {
121+
"type": "string",
122+
"pattern": "^\\w$"
123+
},
124+
"tests": [
125+
{
126+
"description": "ASCII 'a' matches",
127+
"data": "a",
128+
"valid": true
129+
},
130+
{
131+
"description": "latin-1 e-acute does not match (unlike e.g. Python)",
132+
"data": "é",
133+
"valid": false
134+
}
135+
]
136+
},
137+
{
138+
"description": "ECMA 262 \\w matches everything but ascii letters",
139+
"schema": {
140+
"type": "string",
141+
"pattern": "^\\W$"
142+
},
143+
"tests": [
144+
{
145+
"description": "ASCII 'a' does not match",
146+
"data": "a",
147+
"valid": false
148+
},
149+
{
150+
"description": "latin-1 e-acute matches (unlike e.g. Python)",
151+
"data": "é",
152+
"valid": true
153+
}
154+
]
155+
},
156+
{
157+
"description": "ECMA 262 \\s matches ascii whitespace only",
158+
"schema": {
159+
"type": "string",
160+
"pattern": "^\\s$"
161+
},
162+
"tests": [
163+
{
164+
"description": "ASCII space matches",
165+
"data": " ",
166+
"valid": true
167+
},
168+
{
169+
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
170+
"data": "\\u00a0",
171+
"valid": false
172+
}
173+
]
174+
},
175+
{
176+
"description": "ECMA 262 \\S matches everything but ascii whitespace",
177+
"schema": {
178+
"type": "string",
179+
"pattern": "^\\S$"
180+
},
181+
"tests": [
182+
{
183+
"description": "ASCII space does not match",
184+
"data": " ",
185+
"valid": false
186+
},
187+
{
188+
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
189+
"data": "\\u00a0",
190+
"valid": true
191+
}
192+
]
12193
}
13194
]

tests/draft4/optional/ecmascript-regex.json

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,186 @@
99
"valid": false
1010
}
1111
]
12+
},
13+
{
14+
"description": "ECMA 262 regex converts \\a to ascii BEL",
15+
"schema": {
16+
"type": "string",
17+
"pattern": "^\\a$"
18+
},
19+
"tests": [
20+
{
21+
"description": "does not match",
22+
"data": "\\a",
23+
"valid": false
24+
},
25+
{
26+
"description": "matches",
27+
"data": "\u0007",
28+
"valid": true
29+
}
30+
]
31+
},
32+
{
33+
"description": "ECMA 262 regex escapes control codes with \\c and upper letter",
34+
"schema": {
35+
"type": "string",
36+
"pattern": "^\\cC$"
37+
},
38+
"tests": [
39+
{
40+
"description": "does not match",
41+
"data": "\\cC",
42+
"valid": false
43+
},
44+
{
45+
"description": "matches",
46+
"data": "\u0003",
47+
"valid": true
48+
}
49+
]
50+
},
51+
{
52+
"description": "ECMA 262 regex escapes control codes with \\c and lower letter",
53+
"schema": {
54+
"type": "string",
55+
"pattern": "^\\cc$"
56+
},
57+
"tests": [
58+
{
59+
"description": "does not match",
60+
"data": "\\cc",
61+
"valid": false
62+
},
63+
{
64+
"description": "matches",
65+
"data": "\u0003",
66+
"valid": true
67+
}
68+
]
69+
},
70+
{
71+
"description": "ECMA 262 \\d matches ascii digits only",
72+
"schema": {
73+
"type": "string",
74+
"pattern": "^\\d$"
75+
},
76+
"tests": [
77+
{
78+
"description": "ASCII zero matches",
79+
"data": "0",
80+
"valid": true
81+
},
82+
{
83+
"description": "NKO DIGIT ZERO does not match (unlike e.g. Python)",
84+
"data": "߀",
85+
"valid": false
86+
},
87+
{
88+
"description": "NKO DIGIT ZERO (as \\u escape) does not match",
89+
"data": "\\u07c0",
90+
"valid": false
91+
}
92+
]
93+
},
94+
{
95+
"description": "ECMA 262 \\D matches everything but ascii digits",
96+
"schema": {
97+
"type": "string",
98+
"pattern": "^\\D$"
99+
},
100+
"tests": [
101+
{
102+
"description": "ASCII zero does not match",
103+
"data": "0",
104+
"valid": false
105+
},
106+
{
107+
"description": "NKO DIGIT ZERO matches (unlike e.g. Python)",
108+
"data": "߀",
109+
"valid": true
110+
},
111+
{
112+
"description": "NKO DIGIT ZERO (as \\u escape) matches",
113+
"data": "\\u07c0",
114+
"valid": true
115+
}
116+
]
117+
},
118+
{
119+
"description": "ECMA 262 \\w matches ascii letters only",
120+
"schema": {
121+
"type": "string",
122+
"pattern": "^\\w$"
123+
},
124+
"tests": [
125+
{
126+
"description": "ASCII 'a' matches",
127+
"data": "a",
128+
"valid": true
129+
},
130+
{
131+
"description": "latin-1 e-acute does not match (unlike e.g. Python)",
132+
"data": "é",
133+
"valid": false
134+
}
135+
]
136+
},
137+
{
138+
"description": "ECMA 262 \\w matches everything but ascii letters",
139+
"schema": {
140+
"type": "string",
141+
"pattern": "^\\W$"
142+
},
143+
"tests": [
144+
{
145+
"description": "ASCII 'a' does not match",
146+
"data": "a",
147+
"valid": false
148+
},
149+
{
150+
"description": "latin-1 e-acute matches (unlike e.g. Python)",
151+
"data": "é",
152+
"valid": true
153+
}
154+
]
155+
},
156+
{
157+
"description": "ECMA 262 \\s matches ascii whitespace only",
158+
"schema": {
159+
"type": "string",
160+
"pattern": "^\\s$"
161+
},
162+
"tests": [
163+
{
164+
"description": "ASCII space matches",
165+
"data": " ",
166+
"valid": true
167+
},
168+
{
169+
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
170+
"data": "\\u00a0",
171+
"valid": false
172+
}
173+
]
174+
},
175+
{
176+
"description": "ECMA 262 \\S matches everything but ascii whitespace",
177+
"schema": {
178+
"type": "string",
179+
"pattern": "^\\S$"
180+
},
181+
"tests": [
182+
{
183+
"description": "ASCII space does not match",
184+
"data": " ",
185+
"valid": false
186+
},
187+
{
188+
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
189+
"data": "\\u00a0",
190+
"valid": true
191+
}
192+
]
12193
}
13194
]

0 commit comments

Comments
 (0)