Skip to content

Commit c373120

Browse files
committed
[264] Add pattern and patternProperties tests for non-BMP code points
All drafts are affected.
1 parent da35d88 commit c373120

File tree

10 files changed

+440
-0
lines changed

10 files changed

+440
-0
lines changed

tests/draft2019-09/pattern.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,46 @@
5555
"valid": true
5656
}
5757
]
58+
},
59+
{
60+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
61+
"schema": { "pattern": "^🐲*$" },
62+
"tests": [
63+
{
64+
"description": "matches empty",
65+
"data": "",
66+
"valid": true
67+
},
68+
{
69+
"description": "matches single",
70+
"data": "🐲",
71+
"valid": true
72+
},
73+
{
74+
"description": "matches two",
75+
"data": "🐲🐲",
76+
"valid": true
77+
},
78+
{
79+
"description": "doesn't match one",
80+
"data": "🐉",
81+
"valid": false
82+
},
83+
{
84+
"description": "doesn't match two",
85+
"data": "🐉🐉",
86+
"valid": false
87+
},
88+
{
89+
"description": "doesn't match one ASCII",
90+
"data": "D",
91+
"valid": false
92+
},
93+
{
94+
"description": "doesn't match two ASCII",
95+
"data": "DD",
96+
"valid": false
97+
}
98+
]
5899
}
59100
]

tests/draft2019-09/patternProperties.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,52 @@
147147
"valid": true
148148
}
149149
]
150+
},
151+
{
152+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
153+
"schema": {
154+
"patternProperties": {
155+
"^🐲*$": {
156+
"type": "integer"
157+
}
158+
}
159+
},
160+
"tests": [
161+
{
162+
"description": "matches empty",
163+
"data": { "": 1 },
164+
"valid": true
165+
},
166+
{
167+
"description": "matches single",
168+
"data": { "🐲": 1 },
169+
"valid": true
170+
},
171+
{
172+
"description": "matches two",
173+
"data": { "🐲🐲": 1 },
174+
"valid": true
175+
},
176+
{
177+
"description": "doesn't match one",
178+
"data": { "🐉": 1 },
179+
"valid": false
180+
},
181+
{
182+
"description": "doesn't match two",
183+
"data": { "🐉🐉": 1 },
184+
"valid": false
185+
},
186+
{
187+
"description": "doesn't match one ASCII",
188+
"data": { "D": 1 },
189+
"valid": false
190+
},
191+
{
192+
"description": "doesn't match two ASCII",
193+
"data": { "DD": 1 },
194+
"valid": false
195+
}
196+
]
150197
}
151198
]

tests/draft3/pattern.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,46 @@
5555
"valid": true
5656
}
5757
]
58+
},
59+
{
60+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
61+
"schema": { "pattern": "^🐲*$" },
62+
"tests": [
63+
{
64+
"description": "matches empty",
65+
"data": "",
66+
"valid": true
67+
},
68+
{
69+
"description": "matches single",
70+
"data": "🐲",
71+
"valid": true
72+
},
73+
{
74+
"description": "matches two",
75+
"data": "🐲🐲",
76+
"valid": true
77+
},
78+
{
79+
"description": "doesn't match one",
80+
"data": "🐉",
81+
"valid": false
82+
},
83+
{
84+
"description": "doesn't match two",
85+
"data": "🐉🐉",
86+
"valid": false
87+
},
88+
{
89+
"description": "doesn't match one ASCII",
90+
"data": "D",
91+
"valid": false
92+
},
93+
{
94+
"description": "doesn't match two ASCII",
95+
"data": "DD",
96+
"valid": false
97+
}
98+
]
5899
}
59100
]

tests/draft3/patternProperties.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,52 @@
111111
"valid": false
112112
}
113113
]
114+
},
115+
{
116+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
117+
"schema": {
118+
"patternProperties": {
119+
"^🐲*$": {
120+
"type": "integer"
121+
}
122+
}
123+
},
124+
"tests": [
125+
{
126+
"description": "matches empty",
127+
"data": { "": 1 },
128+
"valid": true
129+
},
130+
{
131+
"description": "matches single",
132+
"data": { "🐲": 1 },
133+
"valid": true
134+
},
135+
{
136+
"description": "matches two",
137+
"data": { "🐲🐲": 1 },
138+
"valid": true
139+
},
140+
{
141+
"description": "doesn't match one",
142+
"data": { "🐉": 1 },
143+
"valid": false
144+
},
145+
{
146+
"description": "doesn't match two",
147+
"data": { "🐉🐉": 1 },
148+
"valid": false
149+
},
150+
{
151+
"description": "doesn't match one ASCII",
152+
"data": { "D": 1 },
153+
"valid": false
154+
},
155+
{
156+
"description": "doesn't match two ASCII",
157+
"data": { "DD": 1 },
158+
"valid": false
159+
}
160+
]
114161
}
115162
]

tests/draft4/pattern.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,46 @@
5555
"valid": true
5656
}
5757
]
58+
},
59+
{
60+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
61+
"schema": { "pattern": "^🐲*$" },
62+
"tests": [
63+
{
64+
"description": "matches empty",
65+
"data": "",
66+
"valid": true
67+
},
68+
{
69+
"description": "matches single",
70+
"data": "🐲",
71+
"valid": true
72+
},
73+
{
74+
"description": "matches two",
75+
"data": "🐲🐲",
76+
"valid": true
77+
},
78+
{
79+
"description": "doesn't match one",
80+
"data": "🐉",
81+
"valid": false
82+
},
83+
{
84+
"description": "doesn't match two",
85+
"data": "🐉🐉",
86+
"valid": false
87+
},
88+
{
89+
"description": "doesn't match one ASCII",
90+
"data": "D",
91+
"valid": false
92+
},
93+
{
94+
"description": "doesn't match two ASCII",
95+
"data": "DD",
96+
"valid": false
97+
}
98+
]
5899
}
59100
]

tests/draft4/patternProperties.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,52 @@
116116
"valid": false
117117
}
118118
]
119+
},
120+
{
121+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
122+
"schema": {
123+
"patternProperties": {
124+
"^🐲*$": {
125+
"type": "integer"
126+
}
127+
}
128+
},
129+
"tests": [
130+
{
131+
"description": "matches empty",
132+
"data": { "": 1 },
133+
"valid": true
134+
},
135+
{
136+
"description": "matches single",
137+
"data": { "🐲": 1 },
138+
"valid": true
139+
},
140+
{
141+
"description": "matches two",
142+
"data": { "🐲🐲": 1 },
143+
"valid": true
144+
},
145+
{
146+
"description": "doesn't match one",
147+
"data": { "🐉": 1 },
148+
"valid": false
149+
},
150+
{
151+
"description": "doesn't match two",
152+
"data": { "🐉🐉": 1 },
153+
"valid": false
154+
},
155+
{
156+
"description": "doesn't match one ASCII",
157+
"data": { "D": 1 },
158+
"valid": false
159+
},
160+
{
161+
"description": "doesn't match two ASCII",
162+
"data": { "DD": 1 },
163+
"valid": false
164+
}
165+
]
119166
}
120167
]

tests/draft6/pattern.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,46 @@
5555
"valid": true
5656
}
5757
]
58+
},
59+
{
60+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
61+
"schema": { "pattern": "^🐲*$" },
62+
"tests": [
63+
{
64+
"description": "matches empty",
65+
"data": "",
66+
"valid": true
67+
},
68+
{
69+
"description": "matches single",
70+
"data": "🐲",
71+
"valid": true
72+
},
73+
{
74+
"description": "matches two",
75+
"data": "🐲🐲",
76+
"valid": true
77+
},
78+
{
79+
"description": "doesn't match one",
80+
"data": "🐉",
81+
"valid": false
82+
},
83+
{
84+
"description": "doesn't match two",
85+
"data": "🐉🐉",
86+
"valid": false
87+
},
88+
{
89+
"description": "doesn't match one ASCII",
90+
"data": "D",
91+
"valid": false
92+
},
93+
{
94+
"description": "doesn't match two ASCII",
95+
"data": "DD",
96+
"valid": false
97+
}
98+
]
5899
}
59100
]

tests/draft6/patternProperties.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,52 @@
147147
"valid": true
148148
}
149149
]
150+
},
151+
{
152+
"description": "non-BMP, checks for proper surrogate pair handling for UTF-16",
153+
"schema": {
154+
"patternProperties": {
155+
"^🐲*$": {
156+
"type": "integer"
157+
}
158+
}
159+
},
160+
"tests": [
161+
{
162+
"description": "matches empty",
163+
"data": { "": 1 },
164+
"valid": true
165+
},
166+
{
167+
"description": "matches single",
168+
"data": { "🐲": 1 },
169+
"valid": true
170+
},
171+
{
172+
"description": "matches two",
173+
"data": { "🐲🐲": 1 },
174+
"valid": true
175+
},
176+
{
177+
"description": "doesn't match one",
178+
"data": { "🐉": 1 },
179+
"valid": false
180+
},
181+
{
182+
"description": "doesn't match two",
183+
"data": { "🐉🐉": 1 },
184+
"valid": false
185+
},
186+
{
187+
"description": "doesn't match one ASCII",
188+
"data": { "D": 1 },
189+
"valid": false
190+
},
191+
{
192+
"description": "doesn't match two ASCII",
193+
"data": { "DD": 1 },
194+
"valid": false
195+
}
196+
]
150197
}
151198
]

0 commit comments

Comments
 (0)