Debian Codegraph @

t/additional-tests-draft2020-12/loose-types-const-enum.json

raw
1 [
2 {
3 "description": "type can be inferred from const and enum values",
4 "comment": "in some languages, 6 and '6' are equal in both stringwise and numeric comparisons, but the JSON type model is more strict",
5 "schema": {
6 "properties": {
7 "const_string": { "const": "6" },
8 "const_number": { "const": 6 },
9 "enum_string": { "enum": [ "6" ] },
10 "enum_number": { "enum": [ 6 ] }
11 }
12 },
13 "tests": [
14 {
15 "description": "const numeric value does not match string",
16 "data": { "const_string": 6 },
17 "valid": false
18 },
19 {
20 "description": "const numeric value does match number",
21 "data": { "const_number": 6 },
22 "valid": true
23 },
24 {
25 "description": "const string value matches string",
26 "data": { "const_string": "6" },
27 "valid": true
28 },
29 {
30 "description": "const string value does not match number",
31 "data": { "const_number": "6" },
32 "valid": false
33 },
34 {
35 "description": "enum numeric value does not match string",
36 "data": { "enum_string": 6 },
37 "valid": false
38 },
39 {
40 "description": "enum numeric value does match number",
41 "data": { "enum_number": 6 },
42 "valid": true
43 },
44 {
45 "description": "enum string value matches string",
46 "data": { "enum_string": "6" },
47 "valid": true
48 },
49 {
50 "description": "enum string value does not match number",
51 "data": { "enum_number": "6" },
52 "valid": false
53 }
54 ]
55 }
56 ]