@toon-format/spec 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3",
2
+ "version": "1.4",
3
3
  "category": "encode",
4
4
  "description": "Object encoding - simple objects, nested objects, key encoding",
5
5
  "tests": [
@@ -11,7 +11,7 @@
11
11
  "active": true
12
12
  },
13
13
  "expected": "id: 123\nname: Ada\nactive: true",
14
- "specSection": "6"
14
+ "specSection": "8"
15
15
  },
16
16
  {
17
17
  "name": "encodes null values in objects",
@@ -20,13 +20,13 @@
20
20
  "value": null
21
21
  },
22
22
  "expected": "id: 123\nvalue: null",
23
- "specSection": "6"
23
+ "specSection": "8"
24
24
  },
25
25
  {
26
26
  "name": "encodes empty objects as empty string",
27
27
  "input": {},
28
28
  "expected": "",
29
- "specSection": "6"
29
+ "specSection": "8"
30
30
  },
31
31
  {
32
32
  "name": "quotes string value with colon",
@@ -34,7 +34,7 @@
34
34
  "note": "a:b"
35
35
  },
36
36
  "expected": "note: \"a:b\"",
37
- "specSection": "6"
37
+ "specSection": "7.2"
38
38
  },
39
39
  {
40
40
  "name": "quotes string value with comma",
@@ -42,7 +42,7 @@
42
42
  "note": "a,b"
43
43
  },
44
44
  "expected": "note: \"a,b\"",
45
- "specSection": "6"
45
+ "specSection": "7.2"
46
46
  },
47
47
  {
48
48
  "name": "quotes string value with newline",
@@ -50,7 +50,7 @@
50
50
  "text": "line1\nline2"
51
51
  },
52
52
  "expected": "text: \"line1\\nline2\"",
53
- "specSection": "6"
53
+ "specSection": "7.2"
54
54
  },
55
55
  {
56
56
  "name": "quotes string value with embedded quotes",
@@ -58,7 +58,7 @@
58
58
  "text": "say \"hello\""
59
59
  },
60
60
  "expected": "text: \"say \\\"hello\\\"\"",
61
- "specSection": "6"
61
+ "specSection": "7.2"
62
62
  },
63
63
  {
64
64
  "name": "quotes string value with leading space",
@@ -66,7 +66,7 @@
66
66
  "text": " padded "
67
67
  },
68
68
  "expected": "text: \" padded \"",
69
- "specSection": "6"
69
+ "specSection": "7.2"
70
70
  },
71
71
  {
72
72
  "name": "quotes string value with only spaces",
@@ -74,7 +74,7 @@
74
74
  "text": " "
75
75
  },
76
76
  "expected": "text: \" \"",
77
- "specSection": "6"
77
+ "specSection": "7.2"
78
78
  },
79
79
  {
80
80
  "name": "quotes string value that looks like true",
@@ -82,7 +82,7 @@
82
82
  "v": "true"
83
83
  },
84
84
  "expected": "v: \"true\"",
85
- "specSection": "6"
85
+ "specSection": "7.2"
86
86
  },
87
87
  {
88
88
  "name": "quotes string value that looks like number",
@@ -90,7 +90,7 @@
90
90
  "v": "42"
91
91
  },
92
92
  "expected": "v: \"42\"",
93
- "specSection": "6"
93
+ "specSection": "7.2"
94
94
  },
95
95
  {
96
96
  "name": "quotes string value that looks like negative decimal",
@@ -98,7 +98,7 @@
98
98
  "v": "-7.5"
99
99
  },
100
100
  "expected": "v: \"-7.5\"",
101
- "specSection": "6"
101
+ "specSection": "7.2"
102
102
  },
103
103
  {
104
104
  "name": "quotes key with colon",
@@ -106,7 +106,7 @@
106
106
  "order:id": 7
107
107
  },
108
108
  "expected": "\"order:id\": 7",
109
- "specSection": "6"
109
+ "specSection": "7.3"
110
110
  },
111
111
  {
112
112
  "name": "quotes key with brackets",
@@ -114,7 +114,7 @@
114
114
  "[index]": 5
115
115
  },
116
116
  "expected": "\"[index]\": 5",
117
- "specSection": "6"
117
+ "specSection": "7.3"
118
118
  },
119
119
  {
120
120
  "name": "quotes key with braces",
@@ -122,7 +122,7 @@
122
122
  "{key}": 5
123
123
  },
124
124
  "expected": "\"{key}\": 5",
125
- "specSection": "6"
125
+ "specSection": "7.3"
126
126
  },
127
127
  {
128
128
  "name": "quotes key with comma",
@@ -130,7 +130,7 @@
130
130
  "a,b": 1
131
131
  },
132
132
  "expected": "\"a,b\": 1",
133
- "specSection": "6"
133
+ "specSection": "7.3"
134
134
  },
135
135
  {
136
136
  "name": "quotes key with spaces",
@@ -138,7 +138,7 @@
138
138
  "full name": "Ada"
139
139
  },
140
140
  "expected": "\"full name\": Ada",
141
- "specSection": "6"
141
+ "specSection": "7.3"
142
142
  },
143
143
  {
144
144
  "name": "quotes key with leading hyphen",
@@ -146,7 +146,7 @@
146
146
  "-lead": 1
147
147
  },
148
148
  "expected": "\"-lead\": 1",
149
- "specSection": "6"
149
+ "specSection": "7.3"
150
150
  },
151
151
  {
152
152
  "name": "quotes key with leading and trailing spaces",
@@ -154,7 +154,7 @@
154
154
  " a ": 1
155
155
  },
156
156
  "expected": "\" a \": 1",
157
- "specSection": "6"
157
+ "specSection": "7.3"
158
158
  },
159
159
  {
160
160
  "name": "quotes numeric key",
@@ -162,7 +162,7 @@
162
162
  "123": "x"
163
163
  },
164
164
  "expected": "\"123\": x",
165
- "specSection": "6"
165
+ "specSection": "7.3"
166
166
  },
167
167
  {
168
168
  "name": "quotes empty string key",
@@ -170,7 +170,7 @@
170
170
  "": 1
171
171
  },
172
172
  "expected": "\"\": 1",
173
- "specSection": "6"
173
+ "specSection": "7.3"
174
174
  },
175
175
  {
176
176
  "name": "escapes newline in key",
@@ -178,7 +178,7 @@
178
178
  "line\nbreak": 1
179
179
  },
180
180
  "expected": "\"line\\nbreak\": 1",
181
- "specSection": "6"
181
+ "specSection": "7.1"
182
182
  },
183
183
  {
184
184
  "name": "escapes tab in key",
@@ -186,7 +186,7 @@
186
186
  "tab\there": 2
187
187
  },
188
188
  "expected": "\"tab\\there\": 2",
189
- "specSection": "6"
189
+ "specSection": "7.1"
190
190
  },
191
191
  {
192
192
  "name": "escapes quotes in key",
@@ -194,7 +194,7 @@
194
194
  "he said \"hi\"": 1
195
195
  },
196
196
  "expected": "\"he said \\\"hi\\\"\": 1",
197
- "specSection": "6"
197
+ "specSection": "7.1"
198
198
  },
199
199
  {
200
200
  "name": "encodes deeply nested objects",
@@ -206,7 +206,7 @@
206
206
  }
207
207
  },
208
208
  "expected": "a:\n b:\n c: deep",
209
- "specSection": "6"
209
+ "specSection": "8"
210
210
  },
211
211
  {
212
212
  "name": "encodes empty nested object",
@@ -214,7 +214,7 @@
214
214
  "user": {}
215
215
  },
216
216
  "expected": "user:",
217
- "specSection": "6"
217
+ "specSection": "8"
218
218
  }
219
219
  ]
220
220
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3",
2
+ "version": "1.4",
3
3
  "category": "encode",
4
4
  "description": "Encoding options - lengthMarker option and combinations with delimiters",
5
5
  "tests": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3",
2
+ "version": "1.4",
3
3
  "category": "encode",
4
4
  "description": "Primitive value encoding - strings, numbers, booleans, null",
5
5
  "tests": [
@@ -7,220 +7,245 @@
7
7
  "name": "encodes safe strings without quotes",
8
8
  "input": "hello",
9
9
  "expected": "hello",
10
- "specSection": "5"
10
+ "specSection": "7.2"
11
11
  },
12
12
  {
13
13
  "name": "encodes safe string with underscore and numbers",
14
14
  "input": "Ada_99",
15
15
  "expected": "Ada_99",
16
- "specSection": "5"
16
+ "specSection": "7.2"
17
17
  },
18
18
  {
19
19
  "name": "quotes empty string",
20
20
  "input": "",
21
21
  "expected": "\"\"",
22
- "specSection": "5"
22
+ "specSection": "7.2"
23
23
  },
24
24
  {
25
25
  "name": "quotes string that looks like true",
26
26
  "input": "true",
27
27
  "expected": "\"true\"",
28
- "specSection": "5",
28
+ "specSection": "7.2",
29
29
  "note": "String representation of boolean must be quoted"
30
30
  },
31
31
  {
32
32
  "name": "quotes string that looks like false",
33
33
  "input": "false",
34
34
  "expected": "\"false\"",
35
- "specSection": "5"
35
+ "specSection": "7.2"
36
36
  },
37
37
  {
38
38
  "name": "quotes string that looks like null",
39
39
  "input": "null",
40
40
  "expected": "\"null\"",
41
- "specSection": "5"
41
+ "specSection": "7.2"
42
42
  },
43
43
  {
44
44
  "name": "quotes string that looks like integer",
45
45
  "input": "42",
46
46
  "expected": "\"42\"",
47
- "specSection": "5"
47
+ "specSection": "7.2"
48
48
  },
49
49
  {
50
50
  "name": "quotes string that looks like negative decimal",
51
51
  "input": "-3.14",
52
52
  "expected": "\"-3.14\"",
53
- "specSection": "5"
53
+ "specSection": "7.2"
54
54
  },
55
55
  {
56
56
  "name": "quotes string that looks like scientific notation",
57
57
  "input": "1e-6",
58
58
  "expected": "\"1e-6\"",
59
- "specSection": "5"
59
+ "specSection": "7.2"
60
60
  },
61
61
  {
62
62
  "name": "quotes string with leading zero",
63
63
  "input": "05",
64
64
  "expected": "\"05\"",
65
- "specSection": "5",
65
+ "specSection": "7.2",
66
66
  "note": "Leading zeros make it non-numeric"
67
67
  },
68
68
  {
69
69
  "name": "escapes newline in string",
70
70
  "input": "line1\nline2",
71
71
  "expected": "\"line1\\nline2\"",
72
- "specSection": "5"
72
+ "specSection": "7.1"
73
73
  },
74
74
  {
75
75
  "name": "escapes tab in string",
76
76
  "input": "tab\there",
77
77
  "expected": "\"tab\\there\"",
78
- "specSection": "5"
78
+ "specSection": "7.1"
79
79
  },
80
80
  {
81
81
  "name": "escapes carriage return in string",
82
82
  "input": "return\rcarriage",
83
83
  "expected": "\"return\\rcarriage\"",
84
- "specSection": "5"
84
+ "specSection": "7.1"
85
85
  },
86
86
  {
87
87
  "name": "escapes backslash in string",
88
88
  "input": "C:\\Users\\path",
89
89
  "expected": "\"C:\\\\Users\\\\path\"",
90
- "specSection": "5"
90
+ "specSection": "7.1"
91
91
  },
92
92
  {
93
93
  "name": "quotes string with array-like syntax",
94
94
  "input": "[3]: x,y",
95
95
  "expected": "\"[3]: x,y\"",
96
- "specSection": "5",
96
+ "specSection": "7.2",
97
97
  "note": "Looks like array header"
98
98
  },
99
99
  {
100
100
  "name": "quotes string starting with hyphen-space",
101
101
  "input": "- item",
102
102
  "expected": "\"- item\"",
103
- "specSection": "5",
103
+ "specSection": "7.2",
104
104
  "note": "Looks like list item marker"
105
105
  },
106
+ {
107
+ "name": "quotes single hyphen as object value",
108
+ "input": { "marker": "-" },
109
+ "expected": "marker: \"-\"",
110
+ "specSection": "7.2",
111
+ "note": "Single hyphen must be quoted to avoid list item ambiguity"
112
+ },
113
+ {
114
+ "name": "quotes string starting with hyphen as object value",
115
+ "input": { "note": "- item" },
116
+ "expected": "note: \"- item\"",
117
+ "specSection": "7.2"
118
+ },
119
+ {
120
+ "name": "quotes single hyphen in array",
121
+ "input": { "items": ["-"] },
122
+ "expected": "items[1]: \"-\"",
123
+ "specSection": "7.2"
124
+ },
125
+ {
126
+ "name": "quotes leading-hyphen string in array",
127
+ "input": { "tags": ["a", "- item", "b"] },
128
+ "expected": "tags[3]: a,\"- item\",b",
129
+ "specSection": "7.2"
130
+ },
106
131
  {
107
132
  "name": "quotes string with bracket notation",
108
133
  "input": "[test]",
109
134
  "expected": "\"[test]\"",
110
- "specSection": "5"
135
+ "specSection": "7.2"
111
136
  },
112
137
  {
113
138
  "name": "quotes string with brace notation",
114
139
  "input": "{key}",
115
140
  "expected": "\"{key}\"",
116
- "specSection": "5"
141
+ "specSection": "7.2"
117
142
  },
118
143
  {
119
144
  "name": "encodes Unicode string without quotes",
120
145
  "input": "café",
121
146
  "expected": "café",
122
- "specSection": "5"
147
+ "specSection": "7.2"
123
148
  },
124
149
  {
125
150
  "name": "encodes Chinese characters without quotes",
126
151
  "input": "你好",
127
152
  "expected": "你好",
128
- "specSection": "5"
153
+ "specSection": "7.2"
129
154
  },
130
155
  {
131
156
  "name": "encodes emoji without quotes",
132
157
  "input": "🚀",
133
158
  "expected": "🚀",
134
- "specSection": "5"
159
+ "specSection": "7.2"
135
160
  },
136
161
  {
137
162
  "name": "encodes string with emoji and spaces",
138
163
  "input": "hello 👋 world",
139
164
  "expected": "hello 👋 world",
140
- "specSection": "5"
165
+ "specSection": "7.2"
141
166
  },
142
167
  {
143
168
  "name": "encodes positive integer",
144
169
  "input": 42,
145
170
  "expected": "42",
146
- "specSection": "5"
171
+ "specSection": "2"
147
172
  },
148
173
  {
149
174
  "name": "encodes decimal number",
150
175
  "input": 3.14,
151
176
  "expected": "3.14",
152
- "specSection": "5"
177
+ "specSection": "2"
153
178
  },
154
179
  {
155
180
  "name": "encodes negative integer",
156
181
  "input": -7,
157
182
  "expected": "-7",
158
- "specSection": "5"
183
+ "specSection": "2"
159
184
  },
160
185
  {
161
186
  "name": "encodes zero",
162
187
  "input": 0,
163
188
  "expected": "0",
164
- "specSection": "5"
189
+ "specSection": "2"
165
190
  },
166
191
  {
167
192
  "name": "encodes negative zero as zero",
168
193
  "input": -0,
169
194
  "expected": "0",
170
- "specSection": "5",
195
+ "specSection": "2",
171
196
  "note": "Negative zero normalizes to zero"
172
197
  },
173
198
  {
174
199
  "name": "encodes scientific notation as decimal",
175
200
  "input": 1000000,
176
201
  "expected": "1000000",
177
- "specSection": "5",
202
+ "specSection": "2",
178
203
  "note": "1e6 input, but represented as decimal"
179
204
  },
180
205
  {
181
206
  "name": "encodes small decimal from scientific notation",
182
207
  "input": 0.000001,
183
208
  "expected": "0.000001",
184
- "specSection": "5",
209
+ "specSection": "2",
185
210
  "note": "1e-6 input"
186
211
  },
187
212
  {
188
213
  "name": "encodes large number",
189
214
  "input": 100000000000000000000,
190
215
  "expected": "100000000000000000000",
191
- "specSection": "5",
216
+ "specSection": "2",
192
217
  "note": "1e20"
193
218
  },
194
219
  {
195
220
  "name": "encodes MAX_SAFE_INTEGER",
196
221
  "input": 9007199254740991,
197
222
  "expected": "9007199254740991",
198
- "specSection": "5"
223
+ "specSection": "2"
199
224
  },
200
225
  {
201
226
  "name": "encodes repeating decimal with full precision",
202
227
  "input": 0.3333333333333333,
203
228
  "expected": "0.3333333333333333",
204
- "specSection": "5",
229
+ "specSection": "2",
205
230
  "note": "Result of 1/3 in JavaScript"
206
231
  },
207
232
  {
208
233
  "name": "encodes true",
209
234
  "input": true,
210
235
  "expected": "true",
211
- "specSection": "5"
236
+ "specSection": "2"
212
237
  },
213
238
  {
214
239
  "name": "encodes false",
215
240
  "input": false,
216
241
  "expected": "false",
217
- "specSection": "5"
242
+ "specSection": "2"
218
243
  },
219
244
  {
220
245
  "name": "encodes null",
221
246
  "input": null,
222
247
  "expected": "null",
223
- "specSection": "5"
248
+ "specSection": "2"
224
249
  }
225
250
  ]
226
251
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3",
2
+ "version": "1.4",
3
3
  "category": "encode",
4
4
  "description": "Whitespace and formatting invariants - no trailing spaces, no trailing newlines",
5
5
  "tests": [
@@ -9,7 +9,7 @@
9
9
  "id": 123
10
10
  },
11
11
  "expected": "id: 123",
12
- "specSection": "4",
12
+ "specSection": "12",
13
13
  "note": "Output should not end with newline character"
14
14
  },
15
15
  {
@@ -22,8 +22,23 @@
22
22
  "items": ["a", "b"]
23
23
  },
24
24
  "expected": "user:\n id: 123\n name: Ada\nitems[2]: a,b",
25
- "specSection": "4",
25
+ "specSection": "12",
26
26
  "note": "2-space indentation, no trailing spaces on any line"
27
+ },
28
+ {
29
+ "name": "respects custom indent size option",
30
+ "input": {
31
+ "user": {
32
+ "name": "Ada",
33
+ "role": "admin"
34
+ }
35
+ },
36
+ "expected": "user:\n name: Ada\n role: admin",
37
+ "specSection": "12",
38
+ "options": {
39
+ "indent": 4
40
+ },
41
+ "note": "4-space indentation for nested objects when indent option is set to 4"
27
42
  }
28
43
  ]
29
44
  }
@@ -69,9 +69,8 @@
69
69
  },
70
70
  "lengthMarker": {
71
71
  "type": "string",
72
- "enum": ["#", ""],
73
- "description": "Optional marker to prefix array lengths (encode only)",
74
- "default": ""
72
+ "const": "#",
73
+ "description": "Optional marker to prefix array lengths (encode only). Omit to disable the marker."
75
74
  },
76
75
  "strict": {
77
76
  "type": "boolean",
@@ -95,7 +94,7 @@
95
94
  "type": "string",
96
95
  "description": "Minimum specification version required for this test",
97
96
  "pattern": "^\\d+\\.\\d+$",
98
- "examples": ["1.0", "1.3"]
97
+ "examples": ["1.0", "1.4"]
99
98
  }
100
99
  },
101
100
  "additionalProperties": false