Skip to content

Commit 05fe96a

Browse files
committed
Squashed 'json/' changes from 2903943b..586515ef
586515ef Bump up the length of acceptable descriptions. 0518c651 Merge remote-tracking branch 'Zac-HD/ecma-regex' c0b24317 Tests for ECMA 262 regex dialect b6f79ee6 Merge pull request #281 from Zac-HD/unique-array-of-items 7c206159 Check uniqueItems with array items 2ebedeb9 Regenerate the remotes [just for trailing newlines essentially.] 98bb02a4 Output the trailing newline. 3f44bc76 Uh, this actually should be a native string. f7cc4cbe Sanity check on a non-dying Python. git-subtree-dir: json git-subtree-split: 586515efac8085ea3621c22f7b4d4d01f6349d6e
1 parent a5a5a45 commit 05fe96a

File tree

16 files changed

+1171
-15
lines changed

16 files changed

+1171
-15
lines changed

bin/jsonschema_suite

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ class SanityTests(unittest.TestCase):
9999

100100
def test_all_descriptions_have_reasonable_length(self):
101101
for case in cases(self.test_files):
102-
descript = case["description"]
102+
description = case["description"]
103103
self.assertLess(
104-
len(descript),
105-
60,
106-
"%r is too long! (keep it to less than 60 chars)" % (descript,)
104+
len(description),
105+
70,
106+
"%r is too long! (keep it to less than 70 chars)" % (
107+
description,
108+
),
107109
)
108110

109111
def test_all_descriptions_are_unique(self):
@@ -217,8 +219,9 @@ def main(arguments):
217219
if e.errno != errno.EEXIST:
218220
raise
219221

220-
with open(filepath, "wb") as out_file:
222+
with open(filepath, "w") as out_file:
221223
json.dump(schema, out_file, indent=4, sort_keys=True)
224+
out_file.write("\n")
222225
elif arguments.command == "serve":
223226
try:
224227
from flask import Flask, jsonify

remotes/folder/folderInteger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"type": "integer"
3-
}
3+
}

remotes/integer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"type": "integer"
3-
}
3+
}

remotes/name-defs.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
"$defs": {
33
"orNull": {
44
"anyOf": [
5-
{"type": "null"},
6-
{"$ref": "#"}
5+
{
6+
"type": "null"
7+
},
8+
{
9+
"$ref": "#"
10+
}
711
]
812
}
913
},

remotes/name.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
"definitions": {
33
"orNull": {
44
"anyOf": [
5-
{"type": "null"},
6-
{"$ref": "#"}
5+
{
6+
"type": "null"
7+
},
8+
{
9+
"$ref": "#"
10+
}
711
]
812
}
913
},

remotes/subSchemas.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"integer": {
33
"type": "integer"
4-
},
4+
},
55
"refToInteger": {
66
"$ref": "#/integer"
77
}
8-
}
8+
}

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/draft2019-09/uniqueItems.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,89 @@
8585
"valid": false
8686
}
8787
]
88+
},
89+
{
90+
"description": "uniqueItems with an array of items",
91+
"schema": {
92+
"items": [{"type": "boolean"}, {"type": "boolean"}],
93+
"uniqueItems": true
94+
},
95+
"tests": [
96+
{
97+
"description": "[false, true] from items array is valid",
98+
"data": [false, true],
99+
"valid": true
100+
},
101+
{
102+
"description": "[true, false] from items array is valid",
103+
"data": [true, false],
104+
"valid": true
105+
},
106+
{
107+
"description": "[false, false] from items array is not valid",
108+
"data": [false, false],
109+
"valid": false
110+
},
111+
{
112+
"description": "[true, true] from items array is not valid",
113+
"data": [true, true],
114+
"valid": false
115+
},
116+
{
117+
"description": "unique array extended from [false, true] is valid",
118+
"data": [false, true, "foo", "bar"],
119+
"valid": true
120+
},
121+
{
122+
"description": "unique array extended from [true, false] is valid",
123+
"data": [true, false, "foo", "bar"],
124+
"valid": true
125+
},
126+
{
127+
"description": "non-unique array extended from [false, true] is not valid",
128+
"data": [false, true, "foo", "foo"],
129+
"valid": false
130+
},
131+
{
132+
"description": "non-unique array extended from [true, false] is not valid",
133+
"data": [true, false, "foo", "foo"],
134+
"valid": false
135+
}
136+
]
137+
},
138+
{
139+
"description": "uniqueItems with an array of items and additionalItems=false",
140+
"schema": {
141+
"items": [{"type": "boolean"}, {"type": "boolean"}],
142+
"uniqueItems": true,
143+
"additionalItems": false
144+
},
145+
"tests": [
146+
{
147+
"description": "[false, true] from items array is valid",
148+
"data": [false, true],
149+
"valid": true
150+
},
151+
{
152+
"description": "[true, false] from items array is valid",
153+
"data": [true, false],
154+
"valid": true
155+
},
156+
{
157+
"description": "[false, false] from items array is not valid",
158+
"data": [false, false],
159+
"valid": false
160+
},
161+
{
162+
"description": "[true, true] from items array is not valid",
163+
"data": [true, true],
164+
"valid": false
165+
},
166+
{
167+
"description": "extra items are invalid even if unique",
168+
"data": [false, true, null],
169+
"valid": false
170+
}
171+
]
88172
}
89173
]

0 commit comments

Comments
 (0)