Skip to content

Commit 4628d39

Browse files
committed
Add complex TOML test data case
1 parent 5c72655 commit 4628d39

File tree

4 files changed

+160
-14
lines changed

4 files changed

+160
-14
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
[simple_object]
2+
# Comment
3+
4+
string = "I'm a string."
5+
multiline_string = '''I\'m
6+
a multiline
7+
string'''
8+
9+
integer_1 = 1
10+
integer_2 = +1
11+
integer_3 = -1
12+
13+
float_1 = +1.0
14+
float_2 = 3.1415
15+
float_3 = -0.01
16+
float_4 = 5e+22
17+
float_5 = 1e06
18+
float_6 = -2E-2
19+
float_7 = 6.626e-34
20+
float_8 = 224_617.445_991_228
21+
22+
infinite_1 = inf
23+
infinite_2 = +inf
24+
infinite_3 = -inf
25+
26+
not_a_number_1 = nan
27+
not_a_number_2 = +nan
28+
not_a_number_3 = -nan
29+
30+
hexadecimal_1 = 0xDEADBEEF
31+
hexadecimal_2 = 0xdeadbeef
32+
hexadecimal_3 = 0xdead_beef
33+
34+
octal_1 = 0o01234567
35+
octal_2 = 0o755
36+
37+
binary = 0b11010110
38+
39+
# The null doesn't exists in TOML, but getting a value from an object
40+
# using a non existent key will be validated against the "null" type
41+
# null = Nil # https://github.com/toml-lang/toml/issues/30
42+
43+
boolean_1 = true
44+
boolean_2 = false
45+
46+
# FIXME: dates can't be validated against { "type": "string", "format": "date" }
47+
# because tomli converts them to datetime objects, must be defined as strings
48+
# See https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7.3.1
49+
offset_datetime_1 = 1979-05-27T07:32:00Z
50+
offset_datetime_2 = 1979-05-27T00:32:00-07:00
51+
offset_datetime_3 = 1979-05-27T00:32:00.999999-07:00
52+
offset_datetime_4 = '1979-05-27T07:32:00Z'
53+
offset_datetime_5 = '1979-05-27T00:32:00-07:00'
54+
offset_datetime_6 = '1979-05-27T00:32:00.999999-07:00'
55+
56+
local_datetime_1 = 1979-05-27T07:32:00
57+
local_datetime_2 = 1979-05-27T00:32:00.999999
58+
local_datetime_3 = '1979-05-27T07:32:00'
59+
local_datetime_4 = '1979-05-27T00:32:00.999999'
60+
61+
local_date_1 = 1979-05-27
62+
local_date_2 = '1979-05-27'
63+
64+
local_time_1 = 07:32:00
65+
local_time_2 = 00:32:00.999999
66+
local_time_3 = '07:32:00'
67+
local_time_4 = '00:32:00.999999'
68+
69+
array_1 = ["a", 2, true]
70+
array_2 = [
71+
"b",
72+
3.1,
73+
false,
74+
]
75+
76+
[nested_object_1]
77+
foo = "bar"
78+
79+
nested_object_2 = { foo = "bar" }
80+
81+
[[array_of_objects_1]]
82+
foo = "bar"
83+
[[array_of_objects_1]]
84+
foo = "bar"
85+
86+
[[nested_array_of_objects_1]]
87+
foo = "bar"
88+
[[nested_array_of_objects_1]]
89+
foo = "bar"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"type": "object",
4+
"properties": {
5+
"simple_object": {
6+
"type": "object",
7+
"properties": {
8+
"string": { "type": "string" },
9+
"multiline_string": { "type": "string" },
10+
"integer_1": { "type": "integer" },
11+
"integer_2": { "type": "integer" },
12+
"integer_3": { "type": "integer" },
13+
"float_1": { "type": "number" },
14+
"float_2": { "type": "number" },
15+
"float_3": { "type": "number" },
16+
"float_4": { "type": "number" },
17+
"float_5": { "type": "number" },
18+
"float_6": { "type": "number" },
19+
"float_7": { "type": "number" },
20+
"float_8": { "type": "number" },
21+
"infinite_1": { "type": "number" },
22+
"infinite_2": { "type": "number" },
23+
"infinite_3": { "type": "number" },
24+
"not_a_number_1": { "type": "number" },
25+
"not_a_number_2": { "type": "number" },
26+
"not_a_number_3": { "type": "number" },
27+
"hexadecimal_1": { "type": "number" },
28+
"hexadecimal_2": { "type": "number" },
29+
"hexadecimal_3": { "type": "number" },
30+
"octal_1": { "type": "number" },
31+
"octal_2": { "type": "number" },
32+
"binary": { "type": "number" },
33+
"null": { "type": "null" },
34+
"boolean_1": { "type": "boolean" },
35+
"boolean_2": { "type": "boolean" },
36+
"offset_datetime_4": { "type": "string", "format": "date-time" },
37+
"offset_datetime_5": { "type": "string", "format": "date-time" },
38+
"offset_datetime_6": { "type": "string", "format": "date-time" },
39+
"local_datetime_4": { "type": "string", "format": "date-time" },
40+
"local_datetime_5": { "type": "string", "format": "date-time" },
41+
"local_date_2": { "type": "string", "format": "date" },
42+
"local_time_3": { "type": "string", "format": "time" },
43+
"local_time_4": { "type": "string", "format": "duration" },
44+
"array_1": { "type": "array" },
45+
"array_2": { "type": "array" },
46+
"nested_object_1": {
47+
"type": "object",
48+
"properties": { "foo": { "type": "string" } }
49+
},
50+
"nested_object_2": {
51+
"type": "object",
52+
"properties": { "foo": { "type": "string" } }
53+
},
54+
"array_of_objects_1": {
55+
"type": "array",
56+
"items": {
57+
"type": "object",
58+
"properties": { "foo": { "type": "string" } }
59+
}
60+
},
61+
"nested_array_of_objects_1": {
62+
"type": "array",
63+
"items": {
64+
"type": "object",
65+
"properties": { "foo": { "type": "string" } }
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}

tests/example-files/explicit-schema/positive/simple-toml/instance.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/example-files/explicit-schema/positive/simple-toml/schema.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)