Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b2e9979
test: cover position-specific strict errors in decode/validation-erro…
johannschopplich Oct 2, 2026
70cd82a
test: cover tabs and lone carriage returns as content in decode/white…
johannschopplich Oct 2, 2026
986f49b
test: cover a leading blank line before a root primitive in decode/ro…
johannschopplich Oct 2, 2026
b3fd41b
test: cover header-shaped and empty quoted keys in decode/objects.json
johannschopplich Oct 2, 2026
97ab0a4
test: cover deep nesting and list-item object fields in decode/arrays…
johannschopplich Oct 2, 2026
8d5b15c
test: cover structural strings in cells in decode/arrays-tabular.json
johannschopplich Oct 2, 2026
d09aa2d
test: cover a quoted key with escaped quotes as an array key in decod…
johannschopplich Oct 2, 2026
b20abb5
test: cover header-shaped and empty keys in encode/objects.json
johannschopplich Oct 2, 2026
756ad4f
test: cover deep nesting and structural list items in encode/arrays-n…
johannschopplich Oct 2, 2026
d78f43e
test: cover an empty object as the first list-item field in encode/ar…
johannschopplich Oct 2, 2026
cfbd2dd
test: cover structural strings in cells in encode/arrays-tabular.json
johannschopplich Oct 2, 2026
bf6094e
test: cover a quoted key with escaped quotes as an array key in encod…
johannschopplich Oct 2, 2026
92faf2f
test: drop the new cases that repeat existing coverage
johannschopplich Oct 3, 2026
1d0f478
test: let only the row count reject the count mismatch in a later lis…
johannschopplich Oct 3, 2026
0c92220
test: lead the tabular rows with the quoted structural cell
johannschopplich Oct 3, 2026
d567206
test: name the `__proto__` array header case after its result
johannschopplich Oct 3, 2026
2353705
test: catch the row count mismatch in a later field of a single list …
johannschopplich Oct 5, 2026
cd66f51
test: reduce the quoted list item case to the header-shaped string
johannschopplich Oct 5, 2026
0de30b6
test: follow the empty first field with a sibling field
johannschopplich Oct 5, 2026
c9799bc
test: name the array-of-arrays cases after their list-item position
johannschopplich Oct 5, 2026
9ed2cf4
test: name the escaped-quote header key case like its siblings
johannschopplich Oct 5, 2026
8307d16
test: note why an escaped quote keeps the brackets inside the key
johannschopplich Oct 5, 2026
4053891
test: reduce the tabular cell case to the header-shaped leading cell
johannschopplich Oct 5, 2026
2fb444e
test: shape the quoted key case like an inline array header
johannschopplich Oct 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions tests/fixtures/decode/arrays-nested.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,63 @@
"shouldError": true,
"specSection": "9.4",
"minSpecVersion": "4.1"
},
{
"name": "parses an array of arrays in list-item position",
"input": "[1]:\n - [1]:\n - [1]: 1",
"expected": [
[
[
1
]
]
],
"specSection": "9.4"
},
{
"name": "parses an empty object as the first field of a list-item object",
"input": "items[1]:\n - a:\n b: 1",
"expected": {
"items": [
{
"a": {},
"b": 1
}
]
},
"specSection": "10"
},
{
"name": "parses a tabular array as a later field of a list-item object",
"input": "items[1]:\n - id: 1\n users[2]{id,name}:\n 1,Ada\n 2,Bob",
"expected": {
"items": [
{
"id": 1,
"users": [
{
"id": 1,
"name": "Ada"
},
{
"id": 2,
"name": "Bob"
}
]
}
]
},
"specSection": "10"
},
{
"name": "parses quoted list item shaped like an inline array header",
"input": "xs[1]:\n - \"[2]: x\"",
"expected": {
"xs": [
"[2]: x"
]
},
"specSection": "9.4"
}
]
}
13 changes: 13 additions & 0 deletions tests/fixtures/decode/arrays-primitive.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@
"": []
},
"specSection": "9.1"
},
{
"name": "parses quoted key containing escaped quotes and brackets with inline array",
"input": "\"has \\\"[2]\\\" in it\"[3]: 3,4,5",
"expected": {
"has \"[2]\" in it": [
3,
4,
5
]
},
"specSection": "9.1",
"note": "An escaped quote does not close a quoted key, so the [2] inside it is not a bracket segment"
}
]
}
13 changes: 13 additions & 0 deletions tests/fixtures/decode/arrays-tabular.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@
"specSection": "14.1",
"note": "A declared [N] never truncates a scope",
"minSpecVersion": "4.1"
},
{
"name": "parses quoted leading tabular cell shaped like an inline array header",
"input": "rows[1]{note,id}:\n \"[2]: x\",1",
"expected": {
"rows": [
{
"note": "[2]: x",
"id": 1
}
]
},
"specSection": "9.3"
}
]
}
29 changes: 29 additions & 0 deletions tests/fixtures/decode/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,35 @@
},
"specSection": "7.4",
"minSpecVersion": "4.1"
},
{
"name": "parses quoted empty string key opening a nested object",
"input": "\"\":\n a: 1",
"expected": {
"": {
"a": 1
}
},
"specSection": "8"
},
{
"name": "parses quoted key shaped like an inline array header",
"input": "\"k[2]: y\": 1",
"expected": {
"k[2]: y": 1
},
"specSection": "5.2"
},
{
"name": "materializes __proto__ array header key as an ordinary own key",
"input": "__proto__[2]: 1,2",
"expected": {
"__proto__": [
1,
2
]
},
"specSection": "15"
}
]
}
9 changes: 9 additions & 0 deletions tests/fixtures/decode/root-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@
"strict": true
},
"specSection": "5"
},
{
"name": "parses a root primitive after a leading blank line",
"input": "\nhello",
"expected": "hello",
"options": {
"strict": true
},
"specSection": "5"
}
]
}
63 changes: 63 additions & 0 deletions tests/fixtures/decode/validation-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,69 @@
"specSection": "5.2",
"note": "A scalar line outside root primitive position is an error in strict and non-strict mode alike",
"minSpecVersion": "4.1"
},
{
"name": "throws on the removed [#N] length marker in a root header in strict mode",
"input": "[#2]: a,b",
"expected": null,
"shouldError": true,
"options": {
"strict": true
},
"specSection": "6"
},
{
"name": "throws on the removed [#N] length marker in a field header in strict mode",
"input": "xs[#2]: a,b",
"expected": null,
"shouldError": true,
"options": {
"strict": true
},
"specSection": "6"
},
{
"name": "throws on the removed [#N] length marker in a keyless list-item header in strict mode",
"input": "items[1]:\n - [#2]: a,b",
"expected": null,
"shouldError": true,
"options": {
"strict": true
},
"specSection": "6"
},
{
"name": "throws on the removed [#N] length marker in a list-item first-field header in strict mode",
"input": "items[1]:\n - xs[#2]: a,b",
"expected": null,
"shouldError": true,
"options": {
"strict": true
},
"specSection": "6"
},
{
"name": "throws on tabular row count mismatch in a later field of a list-item object",
"input": "items[1]:\n - id: 1\n users[2]{id,name}:\n 1,Ada",
"expected": null,
"shouldError": true,
"specSection": "14.1"
},
{
"name": "throws on a tab after a quoted value's closing quote",
"input": "k: \"a\"\t",
"expected": null,
"shouldError": true,
"specSection": "7.4",
"minSpecVersion": "4.1"
},
{
"name": "throws on a tab after a quoted key's closing quote",
"input": "\"a\"\t: 1",
"expected": null,
"shouldError": true,
"specSection": "7.4",
"minSpecVersion": "4.1"
}
]
}
27 changes: 27 additions & 0 deletions tests/fixtures/decode/whitespace.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,33 @@
"specSection": "12",
"note": "Trailing spaces are stripped before line classification",
"minSpecVersion": "4.1"
},
{
"name": "keeps a trailing tab in an unquoted value",
"input": "k: v\t",
"expected": {
"k": "v\t"
},
"specSection": "12"
},
{
"name": "keeps a tab after a comma delimiter as part of the token",
"input": "items[2]: a,\tb",
"expected": {
"items": [
"a",
"\tb"
]
},
"specSection": "12"
},
{
"name": "keeps a carriage return inside a line as content",
"input": "a: x\ry",
"expected": {
"a": "x\ry"
},
"specSection": "12"
}
]
}
12 changes: 12 additions & 0 deletions tests/fixtures/encode/arrays-nested.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@
"specSection": "9.3",
"note": "A keyless fields-bearing header is valid only at the document root",
"minSpecVersion": "4.1"
},
{
"name": "uses list form for an array of arrays in list-item position",
"input": [
[
[
1
]
]
],
"expected": "[1]:\n - [1]:\n - [1]: 1",
"specSection": "9.4"
}
]
}
13 changes: 13 additions & 0 deletions tests/fixtures/encode/arrays-objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@
"specSection": "9.5",
"note": "Keyed tabular form is mandated in object-field and root positions, not in a column",
"minSpecVersion": "4.1"
},
{
"name": "places an empty object first field on the hyphen line",
"input": {
"items": [
{
"a": {},
"b": 1
}
]
},
"expected": "items[1]:\n - a:\n b: 1",
"specSection": "10"
}
]
}
10 changes: 10 additions & 0 deletions tests/fixtures/encode/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@
},
"expected": "note: \"#x\"",
"specSection": "7.2"
},
{
"name": "encodes empty string key opening a nested object",
"input": {
"": {
"a": 1
}
},
"expected": "\"\":\n a: 1",
"specSection": "8"
}
]
}
Loading