chore(release): prepare public source release

This commit is contained in:
MercuryToolbox Release
2026-07-18 15:33:01 +08:00
commit 34d6a57f38
510 changed files with 163501 additions and 0 deletions
@@ -0,0 +1,105 @@
{
"version": "3.0",
"category": "encode",
"description": "Nested and mixed array encoding - arrays of arrays, mixed type arrays, root arrays",
"tests": [
{
"name": "encodes nested arrays of primitives",
"input": {
"pairs": [["a", "b"], ["c", "d"]]
},
"expected": "pairs[2]:\n - [2]: a,b\n - [2]: c,d",
"specSection": "9.2"
},
{
"name": "quotes strings containing delimiters in nested arrays",
"input": {
"pairs": [["a", "b"], ["c,d", "e:f", "true"]]
},
"expected": "pairs[2]:\n - [2]: a,b\n - [3]: \"c,d\",\"e:f\",\"true\"",
"specSection": "9.2"
},
{
"name": "encodes empty inner arrays",
"input": {
"pairs": [[], []]
},
"expected": "pairs[2]:\n - [0]:\n - [0]:",
"specSection": "9.2"
},
{
"name": "encodes mixed-length inner arrays",
"input": {
"pairs": [[1], [2, 3]]
},
"expected": "pairs[2]:\n - [1]: 1\n - [2]: 2,3",
"specSection": "9.2"
},
{
"name": "encodes root-level primitive array",
"input": ["x", "y", "true", true, 10],
"expected": "[5]: x,y,\"true\",true,10",
"specSection": "9.1"
},
{
"name": "encodes root-level array of uniform objects in tabular format",
"input": [{ "id": 1 }, { "id": 2 }],
"expected": "[2]{id}:\n 1\n 2",
"specSection": "9.3"
},
{
"name": "encodes root-level array of non-uniform objects in list format",
"input": [{ "id": 1 }, { "id": 2, "name": "Ada" }],
"expected": "[2]:\n - id: 1\n - id: 2\n name: Ada",
"specSection": "9.4"
},
{
"name": "encodes root-level array mixing primitive, object, and array of objects in list format",
"input": ["summary", { "id": 1, "name": "Ada" }, [{ "id": 2 }, { "status": "draft" }]],
"expected": "[3]:\n - summary\n - id: 1\n name: Ada\n - [2]:\n - id: 2\n - status: draft",
"specSection": "9.4"
},
{
"name": "encodes root-level arrays of arrays",
"input": [[1, 2], []],
"expected": "[2]:\n - [2]: 1,2\n - [0]:",
"specSection": "9.2"
},
{
"name": "encodes empty root-level array",
"input": [],
"expected": "[0]:",
"specSection": "9.1"
},
{
"name": "encodes complex nested structure",
"input": {
"user": {
"id": 123,
"name": "Ada",
"tags": ["reading", "gaming"],
"active": true,
"prefs": []
}
},
"expected": "user:\n id: 123\n name: Ada\n tags[2]: reading,gaming\n active: true\n prefs[0]:",
"specSection": "8"
},
{
"name": "uses list format for arrays mixing primitives and objects",
"input": {
"items": [1, { "a": 1 }, "text"]
},
"expected": "items[3]:\n - 1\n - a: 1\n - text",
"specSection": "9.4"
},
{
"name": "uses list format for arrays mixing objects and arrays",
"input": {
"items": [{ "a": 1 }, [1, 2]]
},
"expected": "items[2]:\n - a: 1\n - [2]: 1,2",
"specSection": "9.4"
}
]
}
@@ -0,0 +1,158 @@
{
"version": "3.0",
"category": "encode",
"description": "Arrays of objects encoding - list format for non-uniform objects and complex structures",
"tests": [
{
"name": "uses list format for objects with different fields",
"input": {
"items": [
{ "id": 1, "name": "First" },
{ "id": 2, "name": "Second", "extra": true }
]
},
"expected": "items[2]:\n - id: 1\n name: First\n - id: 2\n name: Second\n extra: true",
"specSection": "9.4"
},
{
"name": "uses list format for objects with nested values",
"input": {
"items": [
{ "id": 1, "nested": { "x": 1 } }
]
},
"expected": "items[1]:\n - id: 1\n nested:\n x: 1",
"specSection": "9.4"
},
{
"name": "preserves field order in list items - array first",
"input": {
"items": [{ "nums": [1, 2, 3], "name": "Ada" }]
},
"expected": "items[1]:\n - nums[3]: 1,2,3\n name: Ada",
"specSection": "10"
},
{
"name": "preserves field order in list items - primitive first",
"input": {
"items": [{ "name": "Ada", "nums": [1, 2, 3] }]
},
"expected": "items[1]:\n - name: Ada\n nums[3]: 1,2,3",
"specSection": "10"
},
{
"name": "uses list format for objects containing arrays of arrays",
"input": {
"items": [
{ "matrix": [[1, 2], [3, 4]], "name": "grid" }
]
},
"expected": "items[1]:\n - matrix[2]:\n - [2]: 1,2\n - [2]: 3,4\n name: grid",
"specSection": "10"
},
{
"name": "uses tabular format for nested uniform object arrays",
"input": {
"items": [
{ "users": [{ "id": 1, "name": "Ada" }, { "id": 2, "name": "Bob" }], "status": "active" }
]
},
"expected": "items[1]:\n - users[2]{id,name}:\n 1,Ada\n 2,Bob\n status: active",
"specSection": "10",
"note": "YAML-style encoding for list-item objects with tabular array as first field"
},
{
"name": "uses list format for nested object arrays with mismatched keys",
"input": {
"items": [
{ "users": [{ "id": 1, "name": "Ada" }, { "id": 2 }], "status": "active" }
]
},
"expected": "items[1]:\n - users[2]:\n - id: 1\n name: Ada\n - id: 2\n status: active",
"specSection": "10"
},
{
"name": "uses list format for objects with multiple array fields",
"input": {
"items": [{ "nums": [1, 2], "tags": ["a", "b"], "name": "test" }]
},
"expected": "items[1]:\n - nums[2]: 1,2\n tags[2]: a,b\n name: test",
"specSection": "10"
},
{
"name": "uses list format for objects with only array fields",
"input": {
"items": [{ "nums": [1, 2, 3], "tags": ["a", "b"] }]
},
"expected": "items[1]:\n - nums[3]: 1,2,3\n tags[2]: a,b",
"specSection": "10"
},
{
"name": "encodes objects with empty arrays in list format",
"input": {
"items": [
{ "name": "Ada", "data": [] }
]
},
"expected": "items[1]:\n - name: Ada\n data[0]:",
"specSection": "10"
},
{
"name": "uses canonical encoding for multi-field list-item objects with tabular arrays",
"input": {
"items": [{ "users": [{ "id": 1 }, { "id": 2 }], "note": "x" }]
},
"expected": "items[1]:\n - users[2]{id}:\n 1\n 2\n note: x",
"specSection": "10",
"note": "Tabular header on hyphen line with rows at depth +2 and sibling fields at depth +1"
},
{
"name": "uses canonical encoding for single-field list-item tabular arrays",
"input": {
"items": [{ "users": [{ "id": 1, "name": "Ada" }, { "id": 2, "name": "Bob" }] }]
},
"expected": "items[1]:\n - users[2]{id,name}:\n 1,Ada\n 2,Bob",
"specSection": "10",
"note": "Tabular header on hyphen line with rows at depth +2"
},
{
"name": "places empty arrays on hyphen line when first",
"input": {
"items": [{ "data": [], "name": "x" }]
},
"expected": "items[1]:\n - data[0]:\n name: x",
"specSection": "10"
},
{
"name": "encodes empty object list items as bare hyphen",
"input": {
"items": ["first", "second", {}]
},
"expected": "items[3]:\n - first\n - second\n -",
"specSection": "10",
"note": "Empty object list items encode as a single \"-\" line at the list-item depth"
},
{
"name": "uses field order from first object for tabular headers",
"input": {
"items": [
{ "a": 1, "b": 2, "c": 3 },
{ "c": 30, "b": 20, "a": 10 }
]
},
"expected": "items[2]{a,b,c}:\n 1,2,3\n 10,20,30",
"specSection": "9.3"
},
{
"name": "uses list format when one object has nested field",
"input": {
"items": [
{ "id": 1, "data": "string" },
{ "id": 2, "data": { "nested": true } }
]
},
"expected": "items[2]:\n - id: 1\n data: string\n - id: 2\n data:\n nested: true",
"specSection": "9.4"
}
]
}
@@ -0,0 +1,103 @@
{
"version": "1.4",
"category": "encode",
"description": "Primitive array encoding - inline arrays of strings, numbers, booleans",
"tests": [
{
"name": "encodes string arrays inline",
"input": {
"tags": ["reading", "gaming"]
},
"expected": "tags[2]: reading,gaming",
"specSection": "9.1"
},
{
"name": "encodes number arrays inline",
"input": {
"nums": [1, 2, 3]
},
"expected": "nums[3]: 1,2,3",
"specSection": "9.1"
},
{
"name": "encodes mixed primitive arrays inline",
"input": {
"data": ["x", "y", true, 10]
},
"expected": "data[4]: x,y,true,10",
"specSection": "9.1"
},
{
"name": "encodes empty arrays",
"input": {
"items": []
},
"expected": "items[0]:",
"specSection": "9.1"
},
{
"name": "encodes empty string keys for inline arrays",
"input": {
"": [1, 2, 3]
},
"expected": "\"\"[3]: 1,2,3",
"specSection": "9.1"
},
{
"name": "encodes empty string keys for empty arrays",
"input": {
"": []
},
"expected": "\"\"[0]:",
"specSection": "9.1"
},
{
"name": "encodes empty string in single-item array",
"input": {
"items": [""]
},
"expected": "items[1]: \"\"",
"specSection": "9.1"
},
{
"name": "encodes empty string in multi-item array",
"input": {
"items": ["a", "", "b"]
},
"expected": "items[3]: a,\"\",b",
"specSection": "9.1"
},
{
"name": "encodes whitespace-only strings in arrays",
"input": {
"items": [" ", " "]
},
"expected": "items[2]: \" \",\" \"",
"specSection": "9.1"
},
{
"name": "quotes array strings with comma",
"input": {
"items": ["a", "b,c", "d:e"]
},
"expected": "items[3]: a,\"b,c\",\"d:e\"",
"specSection": "9.1"
},
{
"name": "quotes strings that look like booleans in arrays",
"input": {
"items": ["x", "true", "42", "-3.14"]
},
"expected": "items[4]: x,\"true\",\"42\",\"-3.14\"",
"specSection": "9.1"
},
{
"name": "quotes strings with structural meanings in arrays",
"input": {
"items": ["[5]", "- item", "{key}"]
},
"expected": "items[3]: \"[5]\",\"- item\",\"{key}\"",
"specSection": "9.1"
}
]
}
@@ -0,0 +1,73 @@
{
"version": "1.4",
"category": "encode",
"description": "Tabular array encoding - arrays of uniform objects with primitive values",
"tests": [
{
"name": "encodes arrays of uniform objects in tabular format",
"input": {
"items": [
{ "sku": "A1", "qty": 2, "price": 9.99 },
{ "sku": "B2", "qty": 1, "price": 14.5 }
]
},
"expected": "items[2]{sku,qty,price}:\n A1,2,9.99\n B2,1,14.5",
"specSection": "9.3"
},
{
"name": "encodes null values in tabular format",
"input": {
"items": [
{ "id": 1, "value": null },
{ "id": 2, "value": "test" }
]
},
"expected": "items[2]{id,value}:\n 1,null\n 2,test",
"specSection": "9.3"
},
{
"name": "quotes strings containing delimiters in tabular rows",
"input": {
"items": [
{ "sku": "A,1", "desc": "cool", "qty": 2 },
{ "sku": "B2", "desc": "wip: test", "qty": 1 }
]
},
"expected": "items[2]{sku,desc,qty}:\n \"A,1\",cool,2\n B2,\"wip: test\",1",
"specSection": "9.3"
},
{
"name": "quotes ambiguous strings in tabular rows",
"input": {
"items": [
{ "id": 1, "status": "true" },
{ "id": 2, "status": "false" }
]
},
"expected": "items[2]{id,status}:\n 1,\"true\"\n 2,\"false\"",
"specSection": "9.3"
},
{
"name": "encodes tabular arrays with keys needing quotes",
"input": {
"items": [
{ "order:id": 1, "full name": "Ada" },
{ "order:id": 2, "full name": "Bob" }
]
},
"expected": "items[2]{\"order:id\",\"full name\"}:\n 1,Ada\n 2,Bob",
"specSection": "9.3"
},
{
"name": "encodes tabular arrays with empty string keys",
"input": {
"": [
{ "id": 1, "name": "Ada" },
{ "id": 2, "name": "Bob" }
]
},
"expected": "\"\"[2]{id,name}:\n 1,Ada\n 2,Bob",
"specSection": "9.3"
}
]
}
+253
View File
@@ -0,0 +1,253 @@
{
"version": "1.4",
"category": "encode",
"description": "Delimiter options - tab and pipe delimiters, delimiter-aware quoting",
"tests": [
{
"name": "encodes primitive arrays with tab delimiter",
"input": {
"tags": ["reading", "gaming", "coding"]
},
"expected": "tags[3\t]: reading\tgaming\tcoding",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "encodes primitive arrays with pipe delimiter",
"input": {
"tags": ["reading", "gaming", "coding"]
},
"expected": "tags[3|]: reading|gaming|coding",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "encodes primitive arrays with comma delimiter",
"input": {
"tags": ["reading", "gaming", "coding"]
},
"expected": "tags[3]: reading,gaming,coding",
"options": {
"delimiter": ","
},
"specSection": "11"
},
{
"name": "encodes tabular arrays with tab delimiter",
"input": {
"items": [
{ "sku": "A1", "qty": 2, "price": 9.99 },
{ "sku": "B2", "qty": 1, "price": 14.5 }
]
},
"expected": "items[2\t]{sku\tqty\tprice}:\n A1\t2\t9.99\n B2\t1\t14.5",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "encodes tabular arrays with pipe delimiter",
"input": {
"items": [
{ "sku": "A1", "qty": 2, "price": 9.99 },
{ "sku": "B2", "qty": 1, "price": 14.5 }
]
},
"expected": "items[2|]{sku|qty|price}:\n A1|2|9.99\n B2|1|14.5",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "encodes nested arrays with tab delimiter",
"input": {
"pairs": [["a", "b"], ["c", "d"]]
},
"expected": "pairs[2\t]:\n - [2\t]: a\tb\n - [2\t]: c\td",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "encodes nested arrays with pipe delimiter",
"input": {
"pairs": [["a", "b"], ["c", "d"]]
},
"expected": "pairs[2|]:\n - [2|]: a|b\n - [2|]: c|d",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "encodes root-level array with tab delimiter",
"input": ["x", "y", "z"],
"expected": "[3\t]: x\ty\tz",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "encodes root-level array with pipe delimiter",
"input": ["x", "y", "z"],
"expected": "[3|]: x|y|z",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "encodes root-level array of objects with tab delimiter",
"input": [{ "id": 1 }, { "id": 2 }],
"expected": "[2\t]{id}:\n 1\n 2",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "encodes root-level array of objects with pipe delimiter",
"input": [{ "id": 1 }, { "id": 2 }],
"expected": "[2|]{id}:\n 1\n 2",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "quotes strings containing tab delimiter",
"input": {
"items": ["a", "b\tc", "d"]
},
"expected": "items[3\t]: a\t\"b\\tc\"\td",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "quotes strings containing pipe delimiter",
"input": {
"items": ["a", "b|c", "d"]
},
"expected": "items[3|]: a|\"b|c\"|d",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "does not quote commas with tab delimiter",
"input": {
"items": ["a,b", "c,d"]
},
"expected": "items[2\t]: a,b\tc,d",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "does not quote commas with pipe delimiter",
"input": {
"items": ["a,b", "c,d"]
},
"expected": "items[2|]: a,b|c,d",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "quotes tabular values containing comma delimiter",
"input": {
"items": [
{ "id": 1, "note": "a,b" },
{ "id": 2, "note": "c,d" }
]
},
"expected": "items[2]{id,note}:\n 1,\"a,b\"\n 2,\"c,d\"",
"options": {
"delimiter": ","
},
"specSection": "11"
},
{
"name": "does not quote commas in tabular values with tab delimiter",
"input": {
"items": [
{ "id": 1, "note": "a,b" },
{ "id": 2, "note": "c,d" }
]
},
"expected": "items[2\t]{id\tnote}:\n 1\ta,b\n 2\tc,d",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "does not quote commas in object values with pipe delimiter",
"input": {
"note": "a,b"
},
"expected": "note: a,b",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "does not quote commas in object values with tab delimiter",
"input": {
"note": "a,b"
},
"expected": "note: a,b",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "quotes nested array values containing pipe delimiter",
"input": {
"pairs": [["a", "b|c"]]
},
"expected": "pairs[1|]:\n - [2|]: a|\"b|c\"",
"options": {
"delimiter": "|"
},
"specSection": "11"
},
{
"name": "quotes nested array values containing tab delimiter",
"input": {
"pairs": [["a", "b\tc"]]
},
"expected": "pairs[1\t]:\n - [2\t]: a\t\"b\\tc\"",
"options": {
"delimiter": "\t"
},
"specSection": "11"
},
{
"name": "preserves ambiguity quoting regardless of delimiter",
"input": {
"items": ["true", "42", "-3.14"]
},
"expected": "items[3|]: \"true\"|\"42\"|\"-3.14\"",
"options": {
"delimiter": "|"
},
"specSection": "11"
}
]
}
+218
View File
@@ -0,0 +1,218 @@
{
"version": "1.5",
"category": "encode",
"description": "Key folding with safe mode, depth control, collision avoidance",
"tests": [
{
"name": "encodes folded chain to primitive (safe mode)",
"input": {
"a": {
"b": {
"c": 1
}
}
},
"expected": "a.b.c: 1",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "encodes folded chain with inline array",
"input": {
"data": {
"meta": {
"items": ["x", "y"]
}
}
},
"expected": "data.meta.items[2]: x,y",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "encodes folded chain with tabular array",
"input": {
"a": {
"b": {
"items": [
{ "id": 1, "name": "A" },
{ "id": 2, "name": "B" }
]
}
}
},
"expected": "a.b.items[2]{id,name}:\n 1,A\n 2,B",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "skips folding when segment requires quotes (safe mode)",
"input": {
"data": {
"full-name": {
"x": 1
}
}
},
"expected": "data:\n \"full-name\":\n x: 1",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "skips folding on sibling literal-key collision (safe mode)",
"input": {
"data": {
"meta": {
"items": [1, 2]
}
},
"data.meta.items": "literal"
},
"expected": "data:\n meta:\n items[2]: 1,2\ndata.meta.items: literal",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4",
"note": "Collision avoidance: folding would create duplicate key"
},
{
"name": "encodes partial folding with flattenDepth=2",
"input": {
"a": {
"b": {
"c": {
"d": 1
}
}
}
},
"expected": "a.b:\n c:\n d: 1",
"options": {
"keyFolding": "safe",
"flattenDepth": 2
},
"specSection": "13.4"
},
{
"name": "encodes full chain with flattenDepth=Infinity (default)",
"input": {
"a": {
"b": {
"c": {
"d": 1
}
}
}
},
"expected": "a.b.c.d: 1",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "encodes standard nesting with flattenDepth=0 (no folding)",
"input": {
"a": {
"b": {
"c": 1
}
}
},
"expected": "a:\n b:\n c: 1",
"options": {
"keyFolding": "safe",
"flattenDepth": 0
},
"specSection": "13.4",
"note": "flattenDepth=0 disables all folding"
},
{
"name": "encodes standard nesting with flattenDepth=1 (no practical effect)",
"input": {
"a": {
"b": {
"c": 1
}
}
},
"expected": "a:\n b:\n c: 1",
"options": {
"keyFolding": "safe",
"flattenDepth": 1
},
"specSection": "13.4",
"note": "flattenDepth=1 has no practical folding effect (requires at least 2 segments)"
},
{
"name": "encodes standard nesting with keyFolding=off (baseline)",
"input": {
"a": {
"b": {
"c": 1
}
}
},
"expected": "a:\n b:\n c: 1",
"options": {
"keyFolding": "off"
},
"specSection": "13.4"
},
{
"name": "encodes folded chain ending with empty object",
"input": {
"a": {
"b": {
"c": {}
}
}
},
"expected": "a.b.c:",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "stops folding at array boundary (not single-key object)",
"input": {
"a": {
"b": [1, 2]
}
},
"expected": "a.b[2]: 1,2",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
},
{
"name": "encodes folded chains preserving sibling field order",
"input": {
"first": {
"second": {
"third": 1
}
},
"simple": 2,
"short": {
"path": 3
}
},
"expected": "first.second.third: 1\nsimple: 2\nshort.path: 3",
"options": {
"keyFolding": "safe"
},
"specSection": "13.4"
}
]
}
+220
View File
@@ -0,0 +1,220 @@
{
"version": "1.4",
"category": "encode",
"description": "Object encoding - simple objects, nested objects, key encoding",
"tests": [
{
"name": "preserves key order in objects",
"input": {
"id": 123,
"name": "Ada",
"active": true
},
"expected": "id: 123\nname: Ada\nactive: true",
"specSection": "8"
},
{
"name": "encodes null values in objects",
"input": {
"id": 123,
"value": null
},
"expected": "id: 123\nvalue: null",
"specSection": "8"
},
{
"name": "encodes empty objects as empty string",
"input": {},
"expected": "",
"specSection": "8"
},
{
"name": "quotes string value with colon",
"input": {
"note": "a:b"
},
"expected": "note: \"a:b\"",
"specSection": "7.2"
},
{
"name": "quotes string value with comma",
"input": {
"note": "a,b"
},
"expected": "note: \"a,b\"",
"specSection": "7.2"
},
{
"name": "quotes string value with newline",
"input": {
"text": "line1\nline2"
},
"expected": "text: \"line1\\nline2\"",
"specSection": "7.2"
},
{
"name": "quotes string value with embedded quotes",
"input": {
"text": "say \"hello\""
},
"expected": "text: \"say \\\"hello\\\"\"",
"specSection": "7.2"
},
{
"name": "quotes string value with leading space",
"input": {
"text": " padded "
},
"expected": "text: \" padded \"",
"specSection": "7.2"
},
{
"name": "quotes string value with only spaces",
"input": {
"text": " "
},
"expected": "text: \" \"",
"specSection": "7.2"
},
{
"name": "quotes string value that looks like true",
"input": {
"v": "true"
},
"expected": "v: \"true\"",
"specSection": "7.2"
},
{
"name": "quotes string value that looks like number",
"input": {
"v": "42"
},
"expected": "v: \"42\"",
"specSection": "7.2"
},
{
"name": "quotes string value that looks like negative decimal",
"input": {
"v": "-7.5"
},
"expected": "v: \"-7.5\"",
"specSection": "7.2"
},
{
"name": "quotes key with colon",
"input": {
"order:id": 7
},
"expected": "\"order:id\": 7",
"specSection": "7.3"
},
{
"name": "quotes key with brackets",
"input": {
"[index]": 5
},
"expected": "\"[index]\": 5",
"specSection": "7.3"
},
{
"name": "quotes key with braces",
"input": {
"{key}": 5
},
"expected": "\"{key}\": 5",
"specSection": "7.3"
},
{
"name": "quotes key with comma",
"input": {
"a,b": 1
},
"expected": "\"a,b\": 1",
"specSection": "7.3"
},
{
"name": "quotes key with spaces",
"input": {
"full name": "Ada"
},
"expected": "\"full name\": Ada",
"specSection": "7.3"
},
{
"name": "quotes key with leading hyphen",
"input": {
"-lead": 1
},
"expected": "\"-lead\": 1",
"specSection": "7.3"
},
{
"name": "quotes key with leading and trailing spaces",
"input": {
" a ": 1
},
"expected": "\" a \": 1",
"specSection": "7.3"
},
{
"name": "quotes numeric key",
"input": {
"123": "x"
},
"expected": "\"123\": x",
"specSection": "7.3"
},
{
"name": "quotes empty string key",
"input": {
"": 1
},
"expected": "\"\": 1",
"specSection": "7.3"
},
{
"name": "escapes newline in key",
"input": {
"line\nbreak": 1
},
"expected": "\"line\\nbreak\": 1",
"specSection": "7.1"
},
{
"name": "escapes tab in key",
"input": {
"tab\there": 2
},
"expected": "\"tab\\there\": 2",
"specSection": "7.1"
},
{
"name": "escapes quotes in key",
"input": {
"he said \"hi\"": 1
},
"expected": "\"he said \\\"hi\\\"\": 1",
"specSection": "7.1"
},
{
"name": "encodes deeply nested objects",
"input": {
"a": {
"b": {
"c": "deep"
}
}
},
"expected": "a:\n b:\n c: deep",
"specSection": "8"
},
{
"name": "encodes empty nested object",
"input": {
"user": {}
},
"expected": "user:",
"specSection": "8"
}
]
}
+251
View File
@@ -0,0 +1,251 @@
{
"version": "1.4",
"category": "encode",
"description": "Primitive value encoding - strings, numbers, booleans, null",
"tests": [
{
"name": "encodes safe strings without quotes",
"input": "hello",
"expected": "hello",
"specSection": "7.2"
},
{
"name": "encodes safe string with underscore and numbers",
"input": "Ada_99",
"expected": "Ada_99",
"specSection": "7.2"
},
{
"name": "quotes empty string",
"input": "",
"expected": "\"\"",
"specSection": "7.2"
},
{
"name": "quotes string that looks like true",
"input": "true",
"expected": "\"true\"",
"specSection": "7.2",
"note": "String representation of boolean must be quoted"
},
{
"name": "quotes string that looks like false",
"input": "false",
"expected": "\"false\"",
"specSection": "7.2"
},
{
"name": "quotes string that looks like null",
"input": "null",
"expected": "\"null\"",
"specSection": "7.2"
},
{
"name": "quotes string that looks like integer",
"input": "42",
"expected": "\"42\"",
"specSection": "7.2"
},
{
"name": "quotes string that looks like negative decimal",
"input": "-3.14",
"expected": "\"-3.14\"",
"specSection": "7.2"
},
{
"name": "quotes string that looks like scientific notation",
"input": "1e-6",
"expected": "\"1e-6\"",
"specSection": "7.2"
},
{
"name": "quotes string with leading zero",
"input": "05",
"expected": "\"05\"",
"specSection": "7.2",
"note": "Leading zeros make it non-numeric"
},
{
"name": "escapes newline in string",
"input": "line1\nline2",
"expected": "\"line1\\nline2\"",
"specSection": "7.1"
},
{
"name": "escapes tab in string",
"input": "tab\there",
"expected": "\"tab\\there\"",
"specSection": "7.1"
},
{
"name": "escapes carriage return in string",
"input": "return\rcarriage",
"expected": "\"return\\rcarriage\"",
"specSection": "7.1"
},
{
"name": "escapes backslash in string",
"input": "C:\\Users\\path",
"expected": "\"C:\\\\Users\\\\path\"",
"specSection": "7.1"
},
{
"name": "quotes string with array-like syntax",
"input": "[3]: x,y",
"expected": "\"[3]: x,y\"",
"specSection": "7.2",
"note": "Looks like array header"
},
{
"name": "quotes string starting with hyphen-space",
"input": "- item",
"expected": "\"- item\"",
"specSection": "7.2",
"note": "Looks like list item marker"
},
{
"name": "quotes single hyphen as object value",
"input": { "marker": "-" },
"expected": "marker: \"-\"",
"specSection": "7.2",
"note": "Single hyphen must be quoted to avoid list item ambiguity"
},
{
"name": "quotes string starting with hyphen as object value",
"input": { "note": "- item" },
"expected": "note: \"- item\"",
"specSection": "7.2"
},
{
"name": "quotes single hyphen in array",
"input": { "items": ["-"] },
"expected": "items[1]: \"-\"",
"specSection": "7.2"
},
{
"name": "quotes leading-hyphen string in array",
"input": { "tags": ["a", "- item", "b"] },
"expected": "tags[3]: a,\"- item\",b",
"specSection": "7.2"
},
{
"name": "quotes string with bracket notation",
"input": "[test]",
"expected": "\"[test]\"",
"specSection": "7.2"
},
{
"name": "quotes string with brace notation",
"input": "{key}",
"expected": "\"{key}\"",
"specSection": "7.2"
},
{
"name": "encodes Unicode string without quotes",
"input": "café",
"expected": "café",
"specSection": "7.2"
},
{
"name": "encodes Chinese characters without quotes",
"input": "你好",
"expected": "你好",
"specSection": "7.2"
},
{
"name": "encodes emoji without quotes",
"input": "🚀",
"expected": "🚀",
"specSection": "7.2"
},
{
"name": "encodes string with emoji and spaces",
"input": "hello 👋 world",
"expected": "hello 👋 world",
"specSection": "7.2"
},
{
"name": "encodes positive integer",
"input": 42,
"expected": "42",
"specSection": "2"
},
{
"name": "encodes decimal number",
"input": 3.14,
"expected": "3.14",
"specSection": "2"
},
{
"name": "encodes negative integer",
"input": -7,
"expected": "-7",
"specSection": "2"
},
{
"name": "encodes zero",
"input": 0,
"expected": "0",
"specSection": "2"
},
{
"name": "encodes negative zero as zero",
"input": -0,
"expected": "0",
"specSection": "2",
"note": "Negative zero normalizes to zero"
},
{
"name": "encodes scientific notation as decimal",
"input": 1000000,
"expected": "1000000",
"specSection": "2",
"note": "1e6 input, but represented as decimal"
},
{
"name": "encodes small decimal from scientific notation",
"input": 0.000001,
"expected": "0.000001",
"specSection": "2",
"note": "1e-6 input"
},
{
"name": "encodes large number",
"input": 100000000000000000000,
"expected": "100000000000000000000",
"specSection": "2",
"note": "1e20"
},
{
"name": "encodes MAX_SAFE_INTEGER",
"input": 9007199254740991,
"expected": "9007199254740991",
"specSection": "2"
},
{
"name": "encodes repeating decimal with full precision",
"input": 0.3333333333333333,
"expected": "0.3333333333333333",
"specSection": "2",
"note": "Result of 1/3 in JavaScript"
},
{
"name": "encodes true",
"input": true,
"expected": "true",
"specSection": "2"
},
{
"name": "encodes false",
"input": false,
"expected": "false",
"specSection": "2"
},
{
"name": "encodes null",
"input": null,
"expected": "null",
"specSection": "2"
}
]
}
+44
View File
@@ -0,0 +1,44 @@
{
"version": "1.4",
"category": "encode",
"description": "Whitespace and formatting invariants - no trailing spaces, no trailing newlines",
"tests": [
{
"name": "produces no trailing newline at end of output",
"input": {
"id": 123
},
"expected": "id: 123",
"specSection": "12",
"note": "Output should not end with newline character"
},
{
"name": "maintains proper indentation for nested structures",
"input": {
"user": {
"id": 123,
"name": "Ada"
},
"items": ["a", "b"]
},
"expected": "user:\n id: 123\n name: Ada\nitems[2]: a,b",
"specSection": "12",
"note": "2-space indentation, no trailing spaces on any line"
},
{
"name": "respects custom indent size option",
"input": {
"user": {
"name": "Ada",
"role": "admin"
}
},
"expected": "user:\n name: Ada\n role: admin",
"specSection": "12",
"options": {
"indent": 4
},
"note": "4-space indentation for nested objects when indent option is set to 4"
}
]
}