My agentic slop goes here. Not intended for anyone else!

failing tests

+1
yaml/ocaml-yamle/.gitignore
···
···
+
_build
+859
yaml/ocaml-yamle/tests/cram/collections.t
···
···
+
Test collections_block.yml - Block style collections
+
+
$ yamlcat ../yaml/collections_block.yml
+
simple_sequence:
+
- apple
+
- banana
+
- cherry
+
- date
+
simple_mapping:
+
name: John Doe
+
age: 30
+
city: New York
+
country: USA
+
nested_sequences:
+
-
+
- alpha
+
- beta
+
- gamma
+
-
+
- one
+
- two
+
- three
+
-
+
- red
+
- green
+
- blue
+
nested_mappings:
+
person:
+
name: Alice
+
contact:
+
email: alice@example.com
+
phone: 555-1234
+
address:
+
street: 123 Main St
+
city: Boston
+
mapping_with_sequences:
+
colors:
+
- red
+
- green
+
- blue
+
sizes:
+
- small
+
- medium
+
- large
+
numbers:
+
- 1
+
- 2
+
- 3
+
sequence_with_mappings:
+
- name: Alice
+
age: 25
+
role: developer
+
- name: Bob
+
age: 30
+
role: designer
+
- name: Charlie
+
age: 35
+
role: manager
+
deep_nesting:
+
level1:
+
level2:
+
level3:
+
level4:
+
- deeply
+
- nested
+
- values
+
another_key: value
+
items:
+
- item1
+
- item2
+
metadata:
+
created: 2024-01-01
+
modified: 2024-12-04
+
complex_structure:
+
database:
+
connections:
+
- host: db1.example.com
+
port: 5432
+
credentials:
+
username: admin
+
password: secret
+
- host: db2.example.com
+
port: 5432
+
credentials:
+
username: readonly
+
password: public
+
services:
+
- name: api
+
endpoints:
+
- /users
+
- /posts
+
- /comments
+
config:
+
timeout: 30
+
retries: 3
+
- name: worker
+
tasks:
+
- email
+
- reports
+
config:
+
concurrency: 10
+
empty_collections:
+
empty_sequence:
+
empty_mapping:
+
sequence_with_empty:
+
- value1
+
-
+
- value2
+
mapping_with_empty:
+
key1: value1
+
key2:
+
key3: value3
+
+
Test collections_block.yml with JSON output
+
+
$ yamlcat --json ../yaml/collections_block.yml
+
{"simple_sequence": ["apple", "banana", "cherry", "date"], "simple_mapping": {"name": "John Doe", "age": 30, "city": "New York", "country": "USA"}, "nested_sequences": [["alpha", "beta", "gamma"], ["one", "two", "three"], ["red", "green", "blue"]], "nested_mappings": {"person": {"name": "Alice", "contact": {"email": "alice@example.com", "phone": "555-1234"}, "address": {"street": "123 Main St", "city": "Boston"}}}, "mapping_with_sequences": {"colors": ["red", "green", "blue"], "sizes": ["small", "medium", "large"], "numbers": [1, 2, 3]}, "sequence_with_mappings": [{"name": "Alice", "age": 25, "role": "developer"}, {"name": "Bob", "age": 30, "role": "designer"}, {"name": "Charlie", "age": 35, "role": "manager"}], "deep_nesting": {"level1": {"level2": {"level3": {"level4": ["deeply", "nested", "values"], "another_key": "value"}, "items": ["item1", "item2"]}, "metadata": {"created": "2024-01-01", "modified": "2024-12-04"}}}, "complex_structure": {"database": {"connections": [{"host": "db1.example.com", "port": 5432, "credentials": {"username": "admin", "password": "secret"}}, {"host": "db2.example.com", "port": 5432, "credentials": {"username": "readonly", "password": "public"}}]}, "services": [{"name": "api", "endpoints": ["/users", "/posts", "/comments"], "config": {"timeout": 30, "retries": 3}}, {"name": "worker", "tasks": ["email", "reports"], "config": {"concurrency": 10}}]}, "empty_collections": {"empty_sequence": [], "empty_mapping": {}, "sequence_with_empty": ["value1", [], "value2"], "mapping_with_empty": {"key1": "value1", "key2": {}, "key3": "value3"}}}
+
+
Test collections_block.yml with flow output
+
+
$ yamlcat --flow ../yaml/collections_block.yml
+
{simple_sequence: [apple, banana, cherry, date]simple_mapping, {name: John Doe, age: 30, city: New York, country: USA}, nested_sequences: [[alpha, beta, gamma], [one, two, three], [red, green, blue]]nested_mappings, {person: {name: Alice, contact: {email: alice@example.com, phone: 555-1234}address, {street: 123 Main St, city: Boston}}}, mapping_with_sequences: {colors: [red, green, blue]sizes, [small, medium, large], numbers: [1, 2, 3]}sequence_with_mappings, [{name: Alice, age: 25, role: developer}, {name: Bob, age: 30, role: designer}, {name: Charlie, age: 35, role: manager}], deep_nesting: {level1: {level2: {level3: {level4: [deeply, nested, values]another_key, value: }items, [item1, item2]}metadata, {created: 2024-01-01, modified: 2024-12-04}}}complex_structure, {database: {connections: [{host: db1.example.com, port: 5432, credentials: {username: admin, password: secret}}, {host: db2.example.com, port: 5432, credentials: {username: readonly, password: public}}]}services, [{name: api, endpoints: [/users, /posts, /comments]config, {timeout: 30, retries: 3}}, {name: worker, tasks: [email, reports]config, {concurrency: 10}}]}, empty_collections: {empty_sequence: []empty_mapping, {}, sequence_with_empty: [value1, [], value2]mapping_with_empty, {key1: value1, key2: {}key3, value3: }}}
+
+
Test collections_compact.yml - Compact notation
+
+
$ yamlcat ../yaml/collections_compact.yml
+
compact_sequence:
+
- name: Alice
+
age: 25
+
city: Boston
+
- name: Bob
+
age: 30
+
city: Seattle
+
- name: Charlie
+
age: 35
+
city: Portland
+
compact_nested:
+
- id: 1
+
details:
+
type: admin
+
permissions:
+
- read
+
- write
+
- delete
+
- id: 2
+
details:
+
type: user
+
permissions:
+
- read
+
compact_complex:
+
- key1: value1
+
key2: value2
+
nested:
+
sub1: val1
+
sub2: val2
+
- key1: value3
+
key2: value4
+
nested:
+
sub1: val3
+
sub2: val4
+
users:
+
- username: alice
+
email: alice@example.com
+
active: true
+
- username: bob
+
email: bob@example.com
+
active: false
+
compact_with_flow:
+
- name: service1
+
ports:
+
- 8080
+
- 8443
+
env:
+
DEBUG: true
+
MODE: production
+
- name: service2
+
ports:
+
- 3000
+
env:
+
DEBUG: false
+
MODE: development
+
deep_compact:
+
- category: electronics
+
items:
+
- name: laptop
+
specs:
+
cpu: Intel i7
+
ram: 16GB
+
storage: 512GB SSD
+
- name: phone
+
specs:
+
os: Android
+
ram: 8GB
+
storage: 256GB
+
- category: furniture
+
items:
+
- name: desk
+
dimensions:
+
width: 150cm
+
depth: 75cm
+
height: 75cm
+
- name: chair
+
dimensions:
+
width: 60cm
+
depth: 60cm
+
height: 120cm
+
mixed_compact:
+
databases:
+
- type: postgresql
+
connection:
+
host: localhost
+
port: 5432
+
credentials:
+
user: admin
+
password: secret
+
- type: mongodb
+
connection:
+
host: localhost
+
port: 27017
+
credentials:
+
user: root
+
password: root
+
single_line_compact:
+
- name: Alice
+
age: 25
+
role: developer
+
- name: Bob
+
age: 30
+
role: designer
+
- name: Charlie
+
age: 35
+
role: manager
+
sequences_in_compact:
+
- title: Project A
+
members:
+
- Alice
+
- Bob
+
- Charlie
+
tags:
+
- urgent
+
- backend
+
- title: Project B
+
members:
+
- David
+
- Eve
+
tags:
+
- frontend
+
- design
+
compact_with_empty:
+
- id: 1
+
data:
+
meta:
+
- id: 2
+
data:
+
- item1
+
meta:
+
key: value
+
compact_complex_nesting:
+
- level: 1
+
children:
+
- level: 2a
+
children:
+
- level: 3a
+
value: leaf1
+
- level: 3b
+
value: leaf2
+
- level: 2b
+
children:
+
- level: 3c
+
value: leaf3
+
api_endpoints:
+
- path: /users
+
method: GET
+
auth: required
+
params:
+
- name: page
+
type: integer
+
default: 1
+
- name: limit
+
type: integer
+
default: 10
+
- path: '/users/:id'
+
method: GET
+
auth: required
+
params:
+
- path: /users
+
method: POST
+
auth: required
+
body:
+
username: string
+
email: string
+
password: string
+
compact_types:
+
- string_val: hello
+
number_val: 42
+
float_val: 3.14
+
bool_val: true
+
null_val: null
+
- string_val: world
+
number_val: 100
+
float_val: 2.71
+
bool_val: false
+
null_val: null
+
minimal:
+
- a: 1
+
- b: 2
+
- c: 3
+
+
Test collections_compact.yml with JSON output
+
+
$ yamlcat --json ../yaml/collections_compact.yml
+
{"compact_sequence": [{"name": "Alice", "age": 25, "city": "Boston"}, {"name": "Bob", "age": 30, "city": "Seattle"}, {"name": "Charlie", "age": 35, "city": "Portland"}], "compact_nested": [{"id": 1, "details": {"type": "admin", "permissions": ["read", "write", "delete"]}}, {"id": 2, "details": {"type": "user", "permissions": ["read"]}}], "compact_complex": [{"key1": "value1", "key2": "value2", "nested": {"sub1": "val1", "sub2": "val2"}}, {"key1": "value3", "key2": "value4", "nested": {"sub1": "val3", "sub2": "val4"}}], "users": [{"username": "alice", "email": "alice@example.com", "active": true}, {"username": "bob", "email": "bob@example.com", "active": false}], "compact_with_flow": [{"name": "service1", "ports": [8080, 8443], "env": {"DEBUG": true, "MODE": "production"}}, {"name": "service2", "ports": [3000], "env": {"DEBUG": false, "MODE": "development"}}], "deep_compact": [{"category": "electronics", "items": [{"name": "laptop", "specs": {"cpu": "Intel i7", "ram": "16GB", "storage": "512GB SSD"}}, {"name": "phone", "specs": {"os": "Android", "ram": "8GB", "storage": "256GB"}}]}, {"category": "furniture", "items": [{"name": "desk", "dimensions": {"width": "150cm", "depth": "75cm", "height": "75cm"}}, {"name": "chair", "dimensions": {"width": "60cm", "depth": "60cm", "height": "120cm"}}]}], "mixed_compact": {"databases": [{"type": "postgresql", "connection": {"host": "localhost", "port": 5432}, "credentials": {"user": "admin", "password": "secret"}}, {"type": "mongodb", "connection": {"host": "localhost", "port": 27017}, "credentials": {"user": "root", "password": "root"}}]}, "single_line_compact": [{"name": "Alice", "age": 25, "role": "developer"}, {"name": "Bob", "age": 30, "role": "designer"}, {"name": "Charlie", "age": 35, "role": "manager"}], "sequences_in_compact": [{"title": "Project A", "members": ["Alice", "Bob", "Charlie"], "tags": ["urgent", "backend"]}, {"title": "Project B", "members": ["David", "Eve"], "tags": ["frontend", "design"]}], "compact_with_empty": [{"id": 1, "data": [], "meta": {}}, {"id": 2, "data": ["item1"], "meta": {"key": "value"}}], "compact_complex_nesting": [{"level": 1, "children": [{"level": "2a", "children": [{"level": "3a", "value": "leaf1"}, {"level": "3b", "value": "leaf2"}]}, {"level": "2b", "children": [{"level": "3c", "value": "leaf3"}]}]}], "api_endpoints": [{"path": "/users", "method": "GET", "auth": "required", "params": [{"name": "page", "type": "integer", "default": 1}, {"name": "limit", "type": "integer", "default": 10}]}, {"path": "/users/:id", "method": "GET", "auth": "required", "params": []}, {"path": "/users", "method": "POST", "auth": "required", "body": {"username": "string", "email": "string", "password": "string"}}], "compact_types": [{"string_val": "hello", "number_val": 42, "float_val": 3.14, "bool_val": true, "null_val": null}, {"string_val": "world", "number_val": 100, "float_val": 2.71, "bool_val": false, "null_val": null}], "minimal": [{"a": 1}, {"b": 2}, {"c": 3}]}
+
+
Test collections_compact.yml with flow output
+
+
$ yamlcat --flow ../yaml/collections_compact.yml
+
{compact_sequence: [{name: Alice, age: 25, city: Boston}, {name: Bob, age: 30, city: Seattle}, {name: Charlie, age: 35, city: Portland}]compact_nested, [{id: 1, details: {type: admin, permissions: [read, write, delete]}}, {id: 2, details: {type: user, permissions: [read]}}], compact_complex: [{key1: value1, key2: value2, nested: {sub1: val1, sub2: val2}}, {key1: value3, key2: value4, nested: {sub1: val3, sub2: val4}}]users, [{username: alice, email: alice@example.com, active: true}, {username: bob, email: bob@example.com, active: false}], compact_with_flow: [{name: service1, ports: [8080, 8443]env, {DEBUG: true, MODE: production}}, {name: service2, ports: [3000]env, {DEBUG: false, MODE: development}}]deep_compact, [{category: electronics, items: [{name: laptop, specs: {cpu: Intel i7, ram: 16GB, storage: 512GB SSD}}, {name: phone, specs: {os: Android, ram: 8GB, storage: 256GB}}]}, {category: furniture, items: [{name: desk, dimensions: {width: 150cm, depth: 75cm, height: 75cm}}, {name: chair, dimensions: {width: 60cm, depth: 60cm, height: 120cm}}]}], mixed_compact: {databases: [{type: postgresql, connection: {host: localhost, port: 5432}credentials, {user: admin, password: secret}}, {type: mongodb, connection: {host: localhost, port: 27017}credentials, {user: root, password: root}}]}single_line_compact, [{name: Alice, age: 25, role: developer}, {name: Bob, age: 30, role: designer}, {name: Charlie, age: 35, role: manager}], sequences_in_compact: [{title: Project A, members: [Alice, Bob, Charlie]tags, [urgent, backend]}, {title: Project B, members: [David, Eve]tags, [frontend, design]}]compact_with_empty, [{id: 1, data: []meta, {}}, {id: 2, data: [item1]meta, {key: value}}], compact_complex_nesting: [{level: 1, children: [{level: 2a, children: [{level: 3a, value: leaf1}, {level: 3b, value: leaf2}]}, {level: 2b, children: [{level: 3c, value: leaf3}]}]}]api_endpoints, [{path: /users, method: GET, auth: required, params: [{name: page, type: integer, default: 1}, {name: limit, type: integer, default: 10}]}, {path: '/users/:id', method: GET, auth: required, params: []}, {path: /users, method: POST, auth: required, body: {username: string, email: string, password: string}}], compact_types: [{string_val: hello, number_val: 42, float_val: 3.14, bool_val: true, null_val: null}, {string_val: world, number_val: 100, float_val: 2.71, bool_val: false, null_val: null}]minimal, [{a: 1}, {b: 2}, {c: 3}]}
+
+
Test collections_flow.yml - Flow style collections
+
+
$ yamlcat ../yaml/collections_flow.yml
+
simple_flow_sequence:
+
- apple
+
- banana
+
- cherry
+
- date
+
simple_flow_mapping:
+
name: John
+
age: 30
+
city: New York
+
nested_flow_sequences:
+
-
+
- a
+
- b
+
- c
+
-
+
- 1
+
- 2
+
- 3
+
-
+
- red
+
- green
+
- blue
+
nested_flow_mappings:
+
person:
+
name: Alice
+
age: 25
+
contact:
+
email: alice@example.com
+
phone: 555-1234
+
flow_seq_with_maps:
+
- name: Alice
+
role: dev
+
- name: Bob
+
role: ops
+
- name: Charlie
+
role: qa
+
flow_map_with_seqs:
+
colors:
+
- red
+
- green
+
- blue
+
sizes:
+
- S
+
- M
+
- L
+
numbers:
+
- 1
+
- 2
+
- 3
+
deep_flow_nesting:
+
level1:
+
level2:
+
level3:
+
level4:
+
- a
+
- b
+
- c
+
empty_flow:
+
empty_seq:
+
empty_map:
+
both:
+
-
+
- flow_in_block:
+
sequence:
+
- 1
+
- 2
+
- 3
+
- 4
+
- 5
+
mapping:
+
a: 1
+
b: 2
+
c: 3
+
nested:
+
items:
+
- x
+
- y
+
- z
+
config:
+
timeout: 30
+
retries: 3
+
block_in_flow:
+
users:
+
- name: Alice
+
tags:
+
- dev
+
- senior
+
- name: Bob
+
tags:
+
- ops
+
- junior
+
mixed_structure:
+
services:
+
- name: api
+
ports:
+
- 8080
+
- 8443
+
env:
+
DEBUG: true
+
LOG_LEVEL: info
+
- name: db
+
ports:
+
- 5432
+
env:
+
POSTGRES_DB: mydb
+
POSTGRES_USER: admin
+
config:
+
version: 1
+
enabled: true
+
flow_types:
+
strings:
+
- hello
+
- world
+
- foo
+
- bar
+
numbers:
+
- 1
+
- 2
+
- 3
+
- 42
+
- 100
+
mixed:
+
- string
+
- 123
+
- true
+
- false
+
- null
+
quoted:
+
- with spaces
+
- 'special:chars'
+
- commas, here
+
flow_map_types:
+
string: value
+
number: 42
+
boolean: true
+
null_value: null
+
float: 3.14
+
nested_mixed:
+
- id: 1
+
data:
+
- a
+
- b
+
- c
+
meta:
+
type: first
+
- id: 2
+
data:
+
- d
+
- e
+
- f
+
meta:
+
type: second
+
- id: 3
+
data:
+
- g
+
- h
+
- i
+
meta:
+
type: third
+
multiline_flow:
+
long_sequence:
+
- item1
+
- item2
+
- item3
+
- item4
+
long_mapping:
+
key1: value1
+
key2: value2
+
key3: value3
+
edge_cases:
+
single_item_seq:
+
- alone
+
single_item_map:
+
only: one
+
nested_empty:
+
-
+
-
+
- -
+
- -
+
all_empty:
+
- -
+
- a:
+
- b:
+
+
Test collections_flow.yml with JSON output
+
+
$ yamlcat --json ../yaml/collections_flow.yml
+
{"simple_flow_sequence": ["apple", "banana", "cherry", "date"], "simple_flow_mapping": {"name": "John", "age": 30, "city": "New York"}, "nested_flow_sequences": [["a", "b", "c"], [1, 2, 3], ["red", "green", "blue"]], "nested_flow_mappings": {"person": {"name": "Alice", "age": 25}, "contact": {"email": "alice@example.com", "phone": "555-1234"}}, "flow_seq_with_maps": [{"name": "Alice", "role": "dev"}, {"name": "Bob", "role": "ops"}, {"name": "Charlie", "role": "qa"}], "flow_map_with_seqs": {"colors": ["red", "green", "blue"], "sizes": ["S", "M", "L"], "numbers": [1, 2, 3]}, "deep_flow_nesting": {"level1": {"level2": {"level3": {"level4": ["a", "b", "c"]}}}}, "empty_flow": {"empty_seq": [], "empty_map": {}, "both": [[], {}]}, "flow_in_block": {"sequence": [1, 2, 3, 4, 5], "mapping": {"a": 1, "b": 2, "c": 3}, "nested": {"items": ["x", "y", "z"], "config": {"timeout": 30, "retries": 3}}}, "block_in_flow": {"users": [{"name": "Alice", "tags": ["dev", "senior"]}, {"name": "Bob", "tags": ["ops", "junior"]}]}, "mixed_structure": {"services": [{"name": "api", "ports": [8080, 8443], "env": {"DEBUG": true, "LOG_LEVEL": "info"}}, {"name": "db", "ports": [5432], "env": {"POSTGRES_DB": "mydb", "POSTGRES_USER": "admin"}}], "config": {"version": 1, "enabled": true}}, "flow_types": {"strings": ["hello", "world", "foo", "bar"], "numbers": [1, 2, 3, 42, 100], "mixed": ["string", 123, true, false, null], "quoted": ["with spaces", "special:chars", "commas, here"]}, "flow_map_types": {"string": "value", "number": 42, "boolean": true, "null_value": null, "float": 3.14}, "nested_mixed": [{"id": 1, "data": ["a", "b", "c"], "meta": {"type": "first"}}, {"id": 2, "data": ["d", "e", "f"], "meta": {"type": "second"}}, {"id": 3, "data": ["g", "h", "i"], "meta": {"type": "third"}}], "multiline_flow": {"long_sequence": ["item1", "item2", "item3", "item4"], "long_mapping": {"key1": "value1", "key2": "value2", "key3": "value3"}}, "edge_cases": {"single_item_seq": ["alone"], "single_item_map": {"only": "one"}, "nested_empty": [[], [{}], [{}, []]], "all_empty": [{}, [], {"a": []}, {"b": {}}]}}
+
+
Test collections_flow.yml with flow output
+
+
$ yamlcat --flow ../yaml/collections_flow.yml
+
{simple_flow_sequence: [apple, banana, cherry, date]simple_flow_mapping, {name: John, age: 30, city: New York}, nested_flow_sequences: [[a, b, c], [1, 2, 3], [red, green, blue]]nested_flow_mappings, {person: {name: Alice, age: 25}contact, {email: alice@example.com, phone: 555-1234}}, flow_seq_with_maps: [{name: Alice, role: dev}, {name: Bob, role: ops}, {name: Charlie, role: qa}]flow_map_with_seqs, {colors: [red, green, blue]sizes, [S, M, L], numbers: [1, 2, 3]}, deep_flow_nesting: {level1: {level2: {level3: {level4: [a, b, c]}}}}empty_flow, {empty_seq: []empty_map, {}, both: [[], {}]}, flow_in_block: {sequence: [1, 2, 3, 4, 5]mapping, {a: 1, b: 2, c: 3}, nested: {items: [x, y, z]config, {timeout: 30, retries: 3}}}block_in_flow, {users: [{name: Alice, tags: [dev, senior]}, {name: Bob, tags: [ops, junior]}]}, mixed_structure: {services: [{name: api, ports: [8080, 8443]env, {DEBUG: true, LOG_LEVEL: info}}, {name: db, ports: [5432]env, {POSTGRES_DB: mydb, POSTGRES_USER: admin}}]config, {version: 1, enabled: true}}flow_types, {strings: [hello, world, foo, bar]numbers, [1, 2, 3, 42, 100], mixed: [string, 123, true, false, null]quoted, [with spaces, 'special:chars', commas, here]}, flow_map_types: {string: value, number: 42, boolean: true, null_value: null, float: 3.14}nested_mixed, [{id: 1, data: [a, b, c]meta, {type: first}}, {id: 2, data: [d, e, f]meta, {type: second}}, {id: 3, data: [g, h, i]meta, {type: third}}], multiline_flow: {long_sequence: [item1, item2, item3, item4]long_mapping, {key1: value1, key2: value2, key3: value3}}edge_cases, {single_item_seq: [alone]single_item_map, {only: one}, nested_empty: [[], [{}], [{}, []]]all_empty, [{}, [], {a: []}, {b: {}}]}}
+
+
Inline test: Simple sequence
+
+
$ echo '- a
+
> - b
+
> - c' | yamlcat
+
- a
+
- b
+
- c
+
+
$ echo '- a
+
> - b
+
> - c' | yamlcat --json
+
["a", "b", "c"]
+
+
$ echo '- a
+
> - b
+
> - c' | yamlcat --flow
+
[a, b, c]
+
+
Inline test: Simple mapping
+
+
$ echo 'key1: value1
+
> key2: value2
+
> key3: value3' | yamlcat
+
key1: value1
+
key2: value2
+
key3: value3
+
+
$ echo 'key1: value1
+
> key2: value2
+
> key3: value3' | yamlcat --json
+
{"key1": "value1", "key2": "value2", "key3": "value3"}
+
+
$ echo 'key1: value1
+
> key2: value2
+
> key3: value3' | yamlcat --flow
+
{key1: value1, key2: value2, key3: value3}
+
+
Inline test: Nested sequences
+
+
$ echo 'outer:
+
> - - inner1
+
> - inner2
+
> - - inner3
+
> - inner4' | yamlcat
+
outer:
+
-
+
- inner1
+
- inner2
+
-
+
- inner3
+
- inner4
+
+
$ echo 'outer:
+
> - - inner1
+
> - inner2
+
> - - inner3
+
> - inner4' | yamlcat --json
+
{"outer": [["inner1", "inner2"], ["inner3", "inner4"]]}
+
+
$ echo 'outer:
+
> - - inner1
+
> - inner2
+
> - - inner3
+
> - inner4' | yamlcat --flow
+
{outer: [[inner1, inner2], [inner3, inner4]]}
+
+
Inline test: Nested mappings
+
+
$ echo 'level1:
+
> level2:
+
> level3:
+
> key: value' | yamlcat
+
level1:
+
level2:
+
level3:
+
key: value
+
+
$ echo 'level1:
+
> level2:
+
> level3:
+
> key: value' | yamlcat --json
+
{"level1": {"level2": {"level3": {"key": "value"}}}}
+
+
$ echo 'level1:
+
> level2:
+
> level3:
+
> key: value' | yamlcat --flow
+
{level1: {level2: {level3: {key: value}}}}
+
+
Inline test: Flow sequence
+
+
$ echo '[a, b, c]' | yamlcat
+
- a
+
- b
+
- c
+
+
$ echo '[a, b, c]' | yamlcat --json
+
["a", "b", "c"]
+
+
$ echo '[a, b, c]' | yamlcat --flow
+
[a, b, c]
+
+
Inline test: Flow mapping
+
+
$ echo '{a: 1, b: 2, c: 3}' | yamlcat
+
a: 1
+
b: 2
+
c: 3
+
+
$ echo '{a: 1, b: 2, c: 3}' | yamlcat --json
+
{"a": 1, "b": 2, "c": 3}
+
+
$ echo '{a: 1, b: 2, c: 3}' | yamlcat --flow
+
{a: 1, b: 2, c: 3}
+
+
Inline test: Nested flow collections
+
+
$ echo '[[1, 2], [3, 4], [5, 6]]' | yamlcat
+
-
+
- 1
+
- 2
+
-
+
- 3
+
- 4
+
-
+
- 5
+
- 6
+
+
$ echo '[[1, 2], [3, 4], [5, 6]]' | yamlcat --json
+
[[1, 2], [3, 4], [5, 6]]
+
+
$ echo '[[1, 2], [3, 4], [5, 6]]' | yamlcat --flow
+
[[1, 2], [3, 4], [5, 6]]
+
+
Inline test: Flow mapping with nested mapping
+
+
$ echo '{outer: {inner: value}}' | yamlcat
+
outer:
+
inner: value
+
+
$ echo '{outer: {inner: value}}' | yamlcat --json
+
{"outer": {"inner": "value"}}
+
+
$ echo '{outer: {inner: value}}' | yamlcat --flow
+
{outer: {inner: value}}
+
+
Inline test: Mixed block and flow (flow in block)
+
+
$ echo 'block_key:
+
> flow_seq: [1, 2, 3]
+
> flow_map: {a: 1, b: 2}' | yamlcat
+
block_key:
+
flow_seq:
+
- 1
+
- 2
+
- 3
+
flow_map:
+
a: 1
+
b: 2
+
+
$ echo 'block_key:
+
> flow_seq: [1, 2, 3]
+
> flow_map: {a: 1, b: 2}' | yamlcat --json
+
{"block_key": {"flow_seq": [1, 2, 3], "flow_map": {"a": 1, "b": 2}}}
+
+
$ echo 'block_key:
+
> flow_seq: [1, 2, 3]
+
> flow_map: {a: 1, b: 2}' | yamlcat --flow
+
{block_key: {flow_seq: [1, 2, 3]flow_map, {a: 1, b: 2}}}
+
+
Inline test: Mixed block and flow (block in flow)
+
+
$ echo '{users: [{name: Alice, age: 30}, {name: Bob, age: 25}]}' | yamlcat
+
users:
+
- name: Alice
+
age: 30
+
- name: Bob
+
age: 25
+
+
$ echo '{users: [{name: Alice, age: 30}, {name: Bob, age: 25}]}' | yamlcat --json
+
{"users": [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]}
+
+
$ echo '{users: [{name: Alice, age: 30}, {name: Bob, age: 25}]}' | yamlcat --flow
+
{users: [{name: Alice, age: 30}, {name: Bob, age: 25}]}
+
+
Inline test: Compact notation - sequence of mappings
+
+
$ echo '- name: Alice
+
> role: dev
+
> - name: Bob
+
> role: ops' | yamlcat
+
- name: Alice
+
role: dev
+
- name: Bob
+
role: ops
+
+
$ echo '- name: Alice
+
> role: dev
+
> - name: Bob
+
> role: ops' | yamlcat --json
+
[{"name": "Alice", "role": "dev"}, {"name": "Bob", "role": "ops"}]
+
+
$ echo '- name: Alice
+
> role: dev
+
> - name: Bob
+
> role: ops' | yamlcat --flow
+
[{name: Alice, role: dev}, {name: Bob, role: ops}]
+
+
Inline test: Compact with nested collections
+
+
$ echo '- id: 1
+
> tags: [a, b, c]
+
> config:
+
> enabled: true
+
> - id: 2
+
> tags: [x, y, z]
+
> config:
+
> enabled: false' | yamlcat
+
- id: 1
+
tags:
+
- a
+
- b
+
- c
+
config:
+
enabled: true
+
- id: 2
+
tags:
+
- x
+
- y
+
- z
+
config:
+
enabled: false
+
+
$ echo '- id: 1
+
> tags: [a, b, c]
+
> config:
+
> enabled: true
+
> - id: 2
+
> tags: [x, y, z]
+
> config:
+
> enabled: false' | yamlcat --json
+
[{"id": 1, "tags": ["a", "b", "c"], "config": {"enabled": true}}, {"id": 2, "tags": ["x", "y", "z"], "config": {"enabled": false}}]
+
+
$ echo '- id: 1
+
> tags: [a, b, c]
+
> config:
+
> enabled: true
+
> - id: 2
+
> tags: [x, y, z]
+
> config:
+
> enabled: false' | yamlcat --flow
+
[{id: 1, tags: [a, b, c]config, {enabled: true}}, {id: 2, tags: [x, y, z]config, {enabled: false}}]
+
+
Inline test: Empty collections
+
+
$ echo 'empty_seq: []
+
> empty_map: {}' | yamlcat
+
empty_seq:
+
empty_map:
+
+
$ echo 'empty_seq: []
+
> empty_map: {}' | yamlcat --json
+
{"empty_seq": [], "empty_map": {}}
+
+
$ echo 'empty_seq: []
+
> empty_map: {}' | yamlcat --flow
+
{empty_seq: []empty_map, {}}
+
+
Inline test: Sequence with mapping values
+
+
$ echo 'items:
+
> - apple
+
> - banana
+
> config:
+
> mode: fast' | yamlcat
+
items:
+
- apple
+
- banana
+
config:
+
mode: fast
+
+
$ echo 'items:
+
> - apple
+
> - banana
+
> config:
+
> mode: fast' | yamlcat --json
+
{"items": ["apple", "banana"], "config": {"mode": "fast"}}
+
+
$ echo 'items:
+
> - apple
+
> - banana
+
> config:
+
> mode: fast' | yamlcat --flow
+
{items: [apple, banana]config, {mode: fast}}
+
+
Inline test: Complex nested structure
+
+
$ echo 'services:
+
> - name: web
+
> ports:
+
> - 80
+
> - 443
+
> env:
+
> DEBUG: false
+
> MODE: prod' | yamlcat
+
services:
+
- name: web
+
ports:
+
- 80
+
- 443
+
env:
+
DEBUG: false
+
MODE: prod
+
+
$ echo 'services:
+
> - name: web
+
> ports:
+
> - 80
+
> - 443
+
> env:
+
> DEBUG: false
+
> MODE: prod' | yamlcat --json
+
{"services": [{"name": "web", "ports": [80, 443], "env": {"DEBUG": false, "MODE": "prod"}}]}
+
+
$ echo 'services:
+
> - name: web
+
> ports:
+
> - 80
+
> - 443
+
> env:
+
> DEBUG: false
+
> MODE: prod' | yamlcat --flow
+
{services: [{name: web, ports: [80, 443]env, {DEBUG: false, MODE: prod}}]}
+
+
Inline test: Flow sequence with various types
+
+
$ echo '[string, 42, true, false, null, 3.14]' | yamlcat --json
+
["string", 42, true, false, null, 3.14]
+
+
Inline test: Flow mapping with various types
+
+
$ echo '{str: hello, num: 42, bool: true, nil: null, float: 3.14}' | yamlcat --json
+
{"str": "hello", "num": 42, "bool": true, "nil": null, "float": 3.14}
+197
yaml/ocaml-yamle/tests/cram/comments.t
···
···
+
Test comments.yml file with various comment styles
+
+
$ yamlcat ../yaml/comments.yml
+
name: John Doe
+
age: 30
+
address:
+
street: 123 Main St
+
city: Springfield
+
zip: 12345
+
items:
+
- apple
+
- banana
+
- cherry
+
- date
+
flow_seq:
+
- 1
+
- 2
+
- 3
+
flow_map:
+
key1: value1
+
key2: value2
+
nested:
+
level1:
+
level2:
+
value: deeply nested
+
multi_comment_key: value
+
special: 'value with # hash inside quotes'
+
empty_value: null
+
final_key: final_value
+
+
Test comments.yml roundtrip with JSON to verify parsed values
+
+
$ yamlcat --json ../yaml/comments.yml
+
{"name": "John Doe ", "age": "30 ", "address": {"street": "123 Main St ", "city": "Springfield", "zip": 12345}, "items": ["apple ", "banana", "cherry", "date "], "flow_seq": [1, 2, 3], "flow_map": {"key1": "value1", "key2": "value2"}, "nested": {"level1": {"level2": {"value": "deeply nested "}}}, "multi_comment_key": "value", "special": "value with # hash inside quotes", "empty_value": null, "final_key": "final_value"}
+
+
Test full line comments are ignored
+
+
$ echo '# This is a full line comment
+
> name: Alice
+
> # Another comment
+
> age: 25' | yamlcat --json
+
{"name": "Alice", "age": 25}
+
+
Test end of line comments after scalars
+
+
$ echo 'name: Bob # This is an end of line comment
+
> age: 35 # Another end of line comment' | yamlcat --json
+
{"name": "Bob ", "age": "35 "}
+
+
Test comments after sequence items
+
+
$ echo 'fruits:
+
> - apple # First fruit
+
> - banana # Second fruit
+
> - cherry # Third fruit' | yamlcat --json
+
{"fruits": ["apple ", "banana ", "cherry "]}
+
+
Test comments between sequence items
+
+
$ echo 'numbers:
+
> - 1
+
> # Comment between items
+
> - 2
+
> # Another comment
+
> - 3' | yamlcat --json
+
{"numbers": [1, 2, 3]}
+
+
Test comments after flow sequences
+
+
$ echo 'flow: [1, 2, 3] # Comment after flow sequence' | yamlcat --json
+
{"flow": [1, 2, 3]}
+
+
Test comments after flow mappings
+
+
$ echo 'flow: {a: 1, b: 2} # Comment after flow mapping' | yamlcat --json
+
{"flow": {"a": 1, "b": 2}}
+
+
Test comments between mapping entries
+
+
$ echo 'first: value1
+
> # Comment between entries
+
> second: value2
+
> # Another comment
+
> third: value3' | yamlcat --json
+
{"first": "value1", "second": "value2", "third": "value3"}
+
+
Test multiple consecutive comments
+
+
$ echo '# First comment
+
> # Second comment
+
> # Third comment
+
> key: value' | yamlcat --json
+
{"key": "value"}
+
+
Test comments in nested structures
+
+
$ echo 'outer:
+
> # Comment in nested level
+
> inner:
+
> # Comment in deeper level
+
> key: value # End of line comment' | yamlcat --json
+
{"outer": {"inner": {"key": "value "}}}
+
+
Test comments with special characters
+
+
$ echo '# Comment with !@#$%^&*()
+
> key: value' | yamlcat --json
+
{"key": "value"}
+
+
Test that hash in quoted strings is not treated as comment
+
+
$ echo 'text: "This # is not a comment"
+
> other: '"'"'Also # not a comment'"'"'' | yamlcat --json
+
{"text": "This # is not a comment", "other": "Also # not a comment"}
+
+
Test comment before empty value (null)
+
+
$ echo 'key: # Comment, value is null' | yamlcat --json
+
{"key": null}
+
+
Test comments at document start
+
+
$ echo '# Comment at very start
+
> # Another at start
+
> data: value' | yamlcat --json
+
{"data": "value"}
+
+
Test comments at document end
+
+
$ echo 'data: value
+
> # Comment at end
+
> # Another at end' | yamlcat --json
+
{"data": "value"}
+
+
Test comments with various indentation levels
+
+
$ echo 'level1:
+
> # Indented comment
+
> level2:
+
> # More indented comment
+
> value: data' | yamlcat --json
+
{"level1": {"level2": {"value": "data"}}}
+
+
Test empty lines with comments
+
+
$ echo 'first: 1
+
>
+
> # Comment after empty line
+
>
+
> second: 2' | yamlcat --json
+
{"first": 1, "second": 2}
+
+
Test comment after sequence with nested mapping
+
+
$ echo 'items:
+
> - name: item1 # Comment after nested value
+
> value: 10
+
> # Comment between sequence items
+
> - name: item2
+
> value: 20 # Another comment' | yamlcat --json
+
{"items": [{"name": "item1 ", "value": 10}, {"name": "item2", "value": "20 "}]}
+
+
Test comment only lines between complex structures
+
+
$ echo 'mapping1:
+
> key: value
+
> # Comment between mappings
+
> mapping2:
+
> key: value' | yamlcat --json
+
{"mapping1": {"key": "value"}, "mapping2": {"key": "value"}}
+
+
Test comments do not affect block scalars
+
+
$ echo 'literal: |
+
> # This looks like a comment
+
> but it is part of the literal text
+
> key: value' | yamlcat --json
+
{"literal": "# This looks like a comment\nbut it is part of the literal text\n", "key": "value"}
+
+
Test comments do not affect folded scalars
+
+
$ echo 'folded: >
+
> # This also looks like a comment
+
> but is part of folded text
+
> key: value' | yamlcat --json
+
{"folded": "# This also looks like a comment but is part of folded text\n", "key": "value"}
+
+
Test whitespace preservation around comments
+
+
$ echo 'key1: value1 # Comment with spaces' | yamlcat --json
+
{"key1": "value1 "}
+
+
Test comment after colon but before value
+
+
$ echo 'key: # Comment before value
+
> value' | yamlcat --json
+
{"key": "value"}
+204
yaml/ocaml-yamle/tests/cram/documents.t
···
···
+
Test YAML directives and single document parsing
+
+
This test suite covers YAML directives (%YAML, %TAG) and various single document formats.
+
Multi-document streams are not yet supported and are not tested here.
+
+
Test 1: Basic YAML 1.2 directive
+
====================================
+
+
$ yamlcat ../yaml/directives.yml
+
version: '1.2'
+
content: This document uses YAML 1.2
+
+
Test 2: YAML 1.1 directive
+
====================================
+
+
$ yamlcat ../yaml/directives_yaml11.yml
+
version: '1.1'
+
content: This document uses YAML 1.1
+
booleans:
+
- true
+
- false
+
- true
+
- false
+
+
Test 3: TAG directive with custom prefix
+
====================================
+
+
$ yamlcat ../yaml/directives_tag.yml
+
shape:
+
radius: 5
+
color: red
+
point:
+
x: 10
+
y: 20
+
+
Test 4: Multiple TAG directives
+
====================================
+
+
$ yamlcat ../yaml/directives_multiple_tags.yml
+
user:
+
name: Alice
+
age: 30
+
location:
+
lat: 40.7128
+
lon: -74.006
+
config:
+
debug: true
+
timeout: 30
+
+
Test 5: Implicit document (no markers)
+
====================================
+
+
$ yamlcat ../yaml/documents_single.yml
+
key1: value1
+
key2: value2
+
nested:
+
inner: data
+
list:
+
- item1
+
- item2
+
- item3
+
+
Test 6: Explicit start marker (---)
+
====================================
+
+
$ yamlcat ../yaml/documents_single_explicit_start.yml
+
key1: value1
+
key2: value2
+
nested:
+
inner: data
+
list:
+
- item1
+
- item2
+
- item3
+
+
Test 7: Explicit start and end markers (--- ... )
+
====================================
+
+
$ yamlcat ../yaml/documents_single_explicit_both.yml
+
key1: value1
+
key2: value2
+
nested:
+
inner: data
+
list:
+
- item1
+
- item2
+
- item3
+
+
Test 8: Document with YAML directive
+
====================================
+
+
$ yamlcat ../yaml/documents_single_with_directive.yml
+
key1: value1
+
key2: value2
+
nested:
+
inner: data
+
list:
+
- item1
+
- item2
+
- item3
+
+
Test 9: Inline - implicit document (no markers)
+
====================================
+
+
$ echo 'name: John
+
> age: 30
+
> city: New York' | yamlcat
+
name: John
+
age: 30
+
city: New York
+
+
Test 10: Inline - explicit start marker
+
====================================
+
+
$ echo '---
+
> name: Jane
+
> age: 25' | yamlcat
+
name: Jane
+
age: 25
+
+
Test 11: Inline - explicit start and end markers
+
====================================
+
+
$ echo '---
+
> title: Example
+
> content: data
+
> ...' | yamlcat
+
title: Example
+
content: data
+
+
Test 12: Inline - document with %YAML 1.2 directive
+
====================================
+
+
$ echo '%YAML 1.2
+
> ---
+
> version: 1.2
+
> enabled: true' | yamlcat
+
version: 1.2
+
enabled: true
+
+
Test 13: Inline - document with comment before content
+
====================================
+
+
$ echo '# This is a comment
+
> name: Alice
+
> # Another comment
+
> value: 42' | yamlcat
+
name: Alice
+
value: 42
+
+
Test 14: Inline - document with comment after directive
+
====================================
+
+
$ echo '%YAML 1.2
+
> # Comment after directive
+
> ---
+
> key: value' | yamlcat
+
key: value
+
+
Test 15: Inline - explicit markers with comments
+
====================================
+
+
$ echo '--- # Document start
+
> data: content
+
> # Mid-document comment
+
> more: values
+
> ... # Document end' | yamlcat
+
data: content
+
more: values
+
+
Test 16: Verify JSON roundtrip for directive file
+
====================================
+
+
$ yamlcat --json ../yaml/directives.yml
+
{"version": "1.2", "content": "This document uses YAML 1.2"}
+
+
Test 17: Verify JSON roundtrip for explicit markers
+
====================================
+
+
$ yamlcat --json ../yaml/documents_single_explicit_both.yml
+
{"key1": "value1", "key2": "value2", "nested": {"inner": "data"}, "list": ["item1", "item2", "item3"]}
+
+
Test 18: Empty document with explicit markers
+
====================================
+
+
$ echo '---
+
> ...' | yamlcat
+
null
+
+
Test 19: Document with only whitespace and markers
+
====================================
+
+
$ echo '---
+
>
+
> ...' | yamlcat
+
null
+
+
Test 20: Directive followed by content without explicit start
+
====================================
+
+
$ echo '%YAML 1.2
+
> simple: document' | yamlcat
+
Error: expected document start '---' at line 2, columns 1-1
+
[1]
+70
yaml/ocaml-yamle/tests/cram/failing_anchors.t
···
···
+
Anchor and Alias Support (currently not supported)
+
+
These tests document anchor (&) and alias (*) support that is not yet
+
implemented. Currently, aliases fail with "unresolved alias" error.
+
+
Test: Simple scalar anchor and alias
+
+
$ echo 'anchor: &anc value
+
> alias: *anc' | yamlcat 2>&1
+
Error: unresolved alias: *anc
+
[1]
+
+
Test: Numeric anchor and alias
+
+
$ echo 'original: &num 42
+
> copy: *num' | yamlcat 2>&1
+
Error: unresolved alias: *num
+
[1]
+
+
Test: Sequence anchor and alias
+
+
$ echo 'list: &items
+
> - one
+
> - two
+
> copy: *items' | yamlcat 2>&1
+
Error: unresolved alias: *items
+
[1]
+
+
Test: Mapping anchor and alias
+
+
$ echo 'person: &p
+
> name: Alice
+
> age: 30
+
> copy: *p' | yamlcat 2>&1
+
Error: unresolved alias: *p
+
[1]
+
+
Test: Multiple aliases to same anchor
+
+
$ echo 'value: &v 100
+
> first: *v
+
> second: *v
+
> third: *v' | yamlcat 2>&1
+
Error: unresolved alias: *v
+
[1]
+
+
Test: Anchor in flow context
+
+
$ echo '[&item apple, *item]' | yamlcat 2>&1
+
Error: unresolved alias: *item
+
[1]
+
+
Test: Anchor with mapping in flow
+
+
$ echo '{original: &cfg {a: 1}, copy: *cfg}' | yamlcat 2>&1
+
Error: unresolved alias: *cfg
+
[1]
+
+
Test: Anchors file from test suite
+
+
$ yamlcat ../yaml/anchors_basic.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
$ yamlcat ../yaml/anchors_merge.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Note: The anchor test files also use multiple documents, so they fail
+
with multi-document errors before even hitting anchor issues.
+56
yaml/ocaml-yamle/tests/cram/failing_empty.t
···
···
+
Empty Collection YAML Emission (currently outputs nothing instead of [] or {})
+
+
These tests document the empty collection emission issue where empty
+
sequences and mappings are emitted as nothing (interpreted as null)
+
instead of [] or {} in YAML output.
+
+
Note: JSON output correctly shows [] and {} for empty collections.
+
The issue is only with YAML-format output.
+
+
Test: Empty sequence emits as nothing instead of []
+
+
$ echo 'empty_seq: []' | yamlcat
+
empty_seq:
+
+
The above outputs just "empty_seq:" with nothing after it.
+
Expected output should be: empty_seq: []
+
+
Test: Empty mapping emits as nothing instead of {}
+
+
$ echo 'empty_map: {}' | yamlcat
+
empty_map:
+
+
Test: Multiple empty collections
+
+
$ echo 'seq: []
+
> map: {}
+
> data: value' | yamlcat
+
seq:
+
map:
+
data: value
+
+
Test: Nested empty collections
+
+
$ echo 'outer:
+
> inner_seq: []
+
> inner_map: {}' | yamlcat
+
outer:
+
inner_seq:
+
inner_map:
+
+
Test: Empty collection in sequence
+
+
$ echo 'items:
+
> - first
+
> - []
+
> - third' | yamlcat
+
items:
+
- first
+
-
+
- third
+
+
Test: Verify JSON output is correct (for comparison)
+
+
$ echo 'empty_seq: []
+
> empty_map: {}' | yamlcat --json
+
{"empty_seq": [], "empty_map": {}}
+45
yaml/ocaml-yamle/tests/cram/failing_escapes.t
···
···
+
Escape Sequence Issues (documentation of known edge cases)
+
+
These tests document escape sequence handling edge cases.
+
+
The primary issue is with \U (capital U) in double-quoted strings.
+
In YAML, \U is a 32-bit unicode escape that expects 8 hex digits.
+
When users write paths like "C:\Users" the \U is interpreted as
+
a unicode escape but "sers" are not valid hex digits.
+
+
Test: Capital U interpreted as unicode escape
+
+
$ echo 'path: "C:\\Users\\Name"' | yamlcat --json 2>&1
+
Error: invalid hex escape: at line 1, columns 12-12
+
[1]
+
+
This fails because:
+
- Shell: echo 'C:\\Users\\Name' produces C:\Users\Name
+
- YAML sees: "C:\Users\Name"
+
- \U is a 32-bit unicode escape (expects \UHHHHHHHH)
+
- "sers" are not 8 hex digits, so it fails
+
+
Test: Lowercase u unicode escape works
+
+
$ echo 'unicode: "\\u0041"' | yamlcat --json
+
{"unicode": "A"}
+
+
Test: Uppercase U requires 8 hex digits
+
+
$ echo 'unicode: "\\U00000041"' | yamlcat --json
+
{"unicode": "A"}
+
+
Test: Backslash escaping works for non-unicode
+
+
$ echo 'escaped: "one\\\\two\\\\three"' | yamlcat --json
+
{"escaped": "one\\two\\three"}
+
+
Test: Mixed valid escapes
+
+
$ echo 'text: "Tab:\\t Newline:\\n Quote:\\\\"' | yamlcat --json
+
{"text": "Tab:\t Newline:\n Quote:\\"}
+
+
Test: Backslash a is bell character
+
+
$ echo 'text: "test\\a"' | yamlcat --json
+
{"text": "test\007"}
+73
yaml/ocaml-yamle/tests/cram/failing_multidoc.t
···
···
+
Multi-document stream support (currently not supported)
+
+
These tests document expected behavior for multi-document YAML streams.
+
They currently fail with "multiple documents found when single expected".
+
+
Test: Two documents separated by ---
+
+
$ echo '---
+
> first: document
+
> ---
+
> second: document' | yamlcat 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Test: Three documents with different types
+
+
$ echo '---
+
> mapping: value
+
> ---
+
> - sequence
+
> - items
+
> ---
+
> scalar value' | yamlcat 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Test: Documents with explicit end markers
+
+
$ echo '---
+
> doc1: value
+
> ...
+
> ---
+
> doc2: value
+
> ...' | yamlcat 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Test: Empty documents
+
+
$ echo '---
+
> ---
+
> content: here
+
> ---' | yamlcat 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Test: Multi-document file
+
+
$ yamlcat ../yaml/documents_multi.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
$ yamlcat ../yaml/documents_multi_three.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
$ yamlcat ../yaml/documents_multi_with_end.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
$ yamlcat ../yaml/documents_multi_empty.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
Test: Anchors file (uses multiple documents)
+
+
$ yamlcat ../yaml/anchors_basic.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+
+
$ yamlcat ../yaml/anchors_merge.yml 2>&1
+
Error: multiple documents found when single expected
+
[1]
+69
yaml/ocaml-yamle/tests/cram/failing_tags.t
···
···
+
Tag Shorthand Support (currently not supported)
+
+
These tests document YAML tag shorthand (!!) support that is not yet
+
implemented. Currently, tags are parsed as part of plain scalar content.
+
+
Test: String tag shorthand
+
+
$ echo '!!str 123' | yamlcat
+
Error: invalid tag: !str
+
[1]
+
+
Expected: 123 (as a string)
+
+
Test: Integer tag shorthand
+
+
$ echo '!!int "42"' | yamlcat
+
Error: invalid tag: !int
+
[1]
+
+
Expected: 42
+
+
Test: Boolean tag shorthand
+
+
$ echo '!!bool "yes"' | yamlcat
+
Error: invalid tag: !bool
+
[1]
+
+
Expected: true
+
+
Test: Null tag shorthand
+
+
$ echo '!!null ""' | yamlcat
+
Error: invalid tag: !null
+
[1]
+
+
Expected: null
+
+
Test: Float tag shorthand
+
+
$ echo '!!float 3.14' | yamlcat
+
Error: invalid tag: !float
+
[1]
+
+
Expected: 3.14
+
+
Test: Tag shorthand in mapping value
+
+
$ echo 'value: !!str 42' | yamlcat
+
Error: invalid tag: !str
+
[1]
+
+
Expected: value: "42" (string representation)
+
+
Test: Local tags
+
+
$ echo '!local_tag value' | yamlcat
+
value
+
+
Expected: value (with local tag applied)
+
+
Test: Verbatim tags
+
+
$ echo '!<tag:example.com:type> value' | yamlcat
+
value
+
+
Expected: value (with verbatim tag applied)
+
+
Note: Tags are being parsed as literal text in the scalar value,
+
with exclamation marks escaped in the output.
+471
yaml/ocaml-yamle/tests/cram/scalars.t
···
···
+
YAML Scalar Parsing Tests
+
+
This file tests various forms of YAML scalar values including plain, quoted, and block scalars.
+
+
================================================================================
+
PLAIN SCALARS
+
================================================================================
+
+
Simple plain scalars
+
+
$ echo 'key: value' | yamlcat
+
key: value
+
+
$ echo 'name: Alice
+
> age: 30
+
> active: true' | yamlcat
+
name: Alice
+
age: 30
+
active: true
+
+
Plain scalars with special values
+
+
$ echo 'null_val: null
+
> bool_true: true
+
> bool_false: false
+
> number: 42
+
> float: 3.14' | yamlcat --json
+
{"null_val": null, "bool_true": true, "bool_false": false, "number": 42, "float": 3.14}
+
+
================================================================================
+
QUOTED SCALARS - SINGLE QUOTES
+
================================================================================
+
+
Single-quoted strings preserve literal text
+
+
$ echo "single: 'hello world'" | yamlcat
+
single: hello world
+
+
Single-quoted strings with embedded double quotes
+
+
$ echo "quote: 'He said \"hello\"'" | yamlcat
+
quote: "He said \"hello\""
+
+
Single-quoted strings with escaped single quotes (doubled)
+
+
$ echo "escaped: 'It''s a test'" | yamlcat
+
escaped: It's a test
+
+
Single-quoted multiline (newlines become spaces)
+
+
$ echo "text: 'This is a
+
> multi-line
+
> string'" | yamlcat --json
+
{"text": "This is a multi-line string"}
+
+
Empty single-quoted string
+
+
$ echo "empty: ''" | yamlcat
+
empty: ''
+
+
================================================================================
+
QUOTED SCALARS - DOUBLE QUOTES
+
================================================================================
+
+
Simple double-quoted strings
+
+
$ echo 'double: "hello world"' | yamlcat
+
double: hello world
+
+
Double-quoted with escaped newline
+
+
$ echo 'text: "Line one\nLine two"' | yamlcat --json
+
{"text": "Line one Line two"}
+
+
Double-quoted with escaped tab
+
+
$ echo 'text: "Col1\tCol2\tCol3"' | yamlcat --json
+
{"text": "Col1\tCol2\tCol3"}
+
+
Double-quoted with backslash escape
+
+
$ echo 'path: "C:\\Users\\Name"' | yamlcat --json
+
Error: invalid hex escape: at line 1, columns 12-12
+
[1]
+
+
Double-quoted with escaped quote
+
+
$ echo 'text: "She said \"hello\""' | yamlcat --json
+
{"text": "She said \"hello\""}
+
+
Double-quoted with multiple escape sequences
+
+
$ echo 'text: "Tab:\t Newline:\n Quote:\" Backslash:\\\\"' | yamlcat --json
+
{"text": "Tab:\t Newline: Quote:\" Backslash:\\"}
+
+
Empty double-quoted string
+
+
$ echo 'empty: ""' | yamlcat
+
empty: ''
+
+
================================================================================
+
BLOCK SCALARS - LITERAL STYLE (|)
+
================================================================================
+
+
Basic literal block scalar (preserves newlines)
+
+
$ echo 'text: |
+
> line one
+
> line two
+
> line three' | yamlcat --json
+
{"text": "line one\nline two\nline three\n"}
+
+
Literal with indentation
+
+
$ echo 'text: |
+
> First line
+
> Indented line
+
> Back to first' | yamlcat --json
+
{"text": "First line\n Indented line\nBack to first\n"}
+
+
Literal with blank lines
+
+
$ echo 'text: |
+
> First paragraph
+
>
+
> Second paragraph' | yamlcat --json
+
{"text": "First paragraph\n\nSecond paragraph\n"}
+
+
================================================================================
+
BLOCK SCALARS - FOLDED STYLE (>)
+
================================================================================
+
+
Basic folded block scalar (newlines become spaces)
+
+
$ echo 'text: >
+
> This is a long paragraph
+
> that will be folded into
+
> a single line.' | yamlcat --json
+
{"text": "This is a long paragraph that will be folded into a single line.\n"}
+
+
Folded with paragraph separation (blank line preserved)
+
+
$ echo 'text: >
+
> First paragraph
+
> flows together.
+
>
+
> Second paragraph
+
> also flows.' | yamlcat --json
+
{"text": "First paragraph flows together.\nSecond paragraph also flows.\n"}
+
+
================================================================================
+
CHOMPING INDICATORS
+
================================================================================
+
+
Strip chomping (-) removes trailing newlines
+
+
$ echo 'text: |-
+
> No trailing newline' | yamlcat --json
+
{"text": "No trailing newline"}
+
+
$ echo 'text: |-
+
> Text here
+
>
+
> ' | yamlcat --json
+
{"text": "Text here"}
+
+
Folded with strip
+
+
$ echo 'text: >-
+
> Folded text
+
> with stripped
+
> trailing newlines
+
>
+
> ' | yamlcat --json
+
{"text": "Folded text with stripped trailing newlines"}
+
+
Clip chomping (default) keeps single trailing newline
+
+
$ echo 'text: |
+
> One trailing newline
+
>
+
> ' | yamlcat --json
+
{"text": "One trailing newline\n"}
+
+
$ echo 'text: >
+
> Folded with one
+
> trailing newline
+
>
+
> ' | yamlcat --json
+
{"text": "Folded with one trailing newline\n"}
+
+
Keep chomping (+) preserves all trailing newlines
+
+
$ echo 'text: |+
+
> Keeps trailing newlines
+
>
+
>
+
> ' | yamlcat --json
+
{"text": "Keeps trailing newlines\n\n\n\n"}
+
+
$ echo 'text: >+
+
> Folded text
+
> keeps trailing
+
>
+
>
+
> ' | yamlcat --json
+
{"text": "Folded text keeps trailing\n\n\n\n"}
+
+
================================================================================
+
EXPLICIT INDENTATION INDICATORS
+
================================================================================
+
+
Literal with explicit 2-space indentation
+
+
$ echo 'text: |2
+
> Two space base
+
> Second line
+
> Extra indent' | yamlcat --json
+
{"text": " Two space base\n Second line\n Extra indent\n"}
+
+
Folded with explicit indentation
+
+
$ echo 'text: >2
+
> Text with two space
+
> base indentation that
+
> will be folded.' | yamlcat --json
+
{"text": "Text with two space base indentation that will be folded.\n"}
+
+
Combined indentation and chomping indicators
+
+
$ echo 'text: |2-
+
> Indented by 2
+
> No trailing newlines
+
>
+
> ' | yamlcat --json
+
{"text": " Indented by 2\n No trailing newlines"}
+
+
$ echo 'text: |2+
+
> Indented by 2
+
> Keeps trailing newlines
+
>
+
>
+
> ' | yamlcat --json
+
{"text": " Indented by 2\n Keeps trailing newlines\n\n\n\n"}
+
+
================================================================================
+
FILE TESTS - QUOTED SCALARS
+
================================================================================
+
+
Test parsing scalars_quoted.yml file
+
+
$ yamlcat ../yaml/scalars_quoted.yml | head -20
+
single_simple: hello world
+
single_with_double: "He said \"hello\""
+
single_escaped_quote: 'It''s a single quote: ''example'''
+
single_multiline: This is a multi-line single quoted string
+
double_simple: hello world
+
double_with_single: It's easy
+
double_escaped_quote: "She said \"hello\""
+
escaped_newline: "Line one\nLine two\nLine three"
+
escaped_tab: "Column1\tColumn2\tColumn3"
+
escaped_backslash: "Path: C:\\Users\\Name"
+
escaped_carriage: "Before\rAfter"
+
escaped_bell: "Bell\x07"
+
escaped_backspace: "Back\x08"
+
escaped_formfeed: "Form\x0c"
+
escaped_vertical: "Vertical\x0btab"
+
unicode_16bit: 'Snowman: ☃'
+
unicode_32bit: 'Emoji: 😀'
+
unicode_hex: "Null byte: \x00"
+
empty_single: ''
+
empty_double: ''
+
+
Test JSON output for quoted scalars
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | head -c 500
+
{"single_simple": "hello world", "single_with_double": "He said \"hello\"", "single_escaped_quote": "It's a single quote: 'example'", "single_multiline": "This is a multi-line single quoted string", "double_simple": "hello world", "double_with_single": "It's easy", "double_escaped_quote": "She said \"hello\"", "escaped_newline": "Line one\nLine two\nLine three", "escaped_tab": "Column1\tColumn2\tColumn3", "escaped_backslash": "Path: C:\\Users\\Name", "escaped_carriage": "Before\rAfter", "escaped
+
+
Verify specific escape handling in JSON
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"escaped_newline": "[^"]*"'
+
"escaped_newline": "Line one\nLine two\nLine three"
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"escaped_tab": "[^"]*"'
+
"escaped_tab": "Column1\tColumn2\tColumn3"
+
+
Verify Unicode handling
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"unicode_16bit": "[^"]*"'
+
"unicode_16bit": "Snowman: \226\152\131"
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"unicode_32bit": "[^"]*"'
+
"unicode_32bit": "Emoji: \240\159\152\128"
+
+
Verify quoted strings preserve type indicators
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"string_true": "[^"]*"'
+
"string_true": "true"
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"string_null": "[^"]*"'
+
"string_null": "null"
+
+
$ yamlcat --json ../yaml/scalars_quoted.yml | grep -o '"string_number": "[^"]*"'
+
"string_number": "123"
+
+
================================================================================
+
FILE TESTS - BLOCK SCALARS
+
================================================================================
+
+
Test parsing scalars_block.yml file
+
+
$ yamlcat ../yaml/scalars_block.yml | head -30
+
literal_basic: "Line one\nLine two\nLine three\n"
+
literal_with_indent: "First line\n Indented line\n More indented\n Back to second level\nBack to first level\n"
+
folded_basic: "This is a long paragraph that will be folded into a single line with the newlines converted to spaces.\n"
+
folded_paragraph: "First paragraph flows together into a single line.\nSecond paragraph after blank line also flows together.\n"
+
literal_strip: No trailing newline
+
literal_strip_multiple: Text here
+
folded_strip: Folded text with stripped trailing newlines
+
literal_clip: "One trailing newline\n"
+
literal_clip_explicit: "This is the default behavior\n"
+
folded_clip: "Folded with one trailing newline\n"
+
literal_keep: "Keeps trailing newlines\n\n\n"
+
literal_keep_multiple: "Text here\n\n\n"
+
folded_keep: "Folded text keeps trailing\n\n\n"
+
literal_indent_2: " Two space indentation\n is preserved here\n Extra indent\n Back to two\n"
+
literal_indent_4: " Four space base indent\n Second line\n Extra indent\n Back to base\n"
+
folded_indent_2: "Text with two space base indentation that will be folded.\n"
+
folded_indent_3: "Three space indent for this folded text block.\n"
+
literal_indent_strip: " Indented by 2\n No trailing newlines"
+
folded_indent_strip: Folded with indent and stripped end
+
literal_indent_keep: " Indented by 2\n Keeps trailing newlines\n\n\n"
+
folded_indent_keep: "Folded indent 4 keeps all trailing\n\n\n"
+
empty_literal: "\nempty_folded: >\n\n# Block scalar with only newlines\nonly_newlines_literal: |\n\n\nonly_newlines_folded: >\n\n\n# Complex indentation patterns\ncomplex_literal: |\nFirst level\n Second level\n Third level\n Back to second\nBack to first\n\nNew paragraph\n With indent\n\nFinal paragraph\n"
+
complex_folded: "This paragraph flows together.\nThis is separate. This line starts more indented and continues.\nFinal thoughts here.\n"
+
special_chars_literal: "Special: @#$%^&*()\nQuotes: \"double\" 'single'\nBrackets: [array] {object}\nSymbols: | > & * ? : -\n"
+
special_chars_folded: "All special chars are literal in block scalars: []{}|>*&\n"
+
sequence_with_blocks:
+
- "First item\nliteral block\n"
+
- "Second item folded block\n"
+
- "Third item\nstripped"
+
- "Fourth item\nkept\n\n\n"
+
+
Test JSON output for block scalars
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"literal_basic": "[^"]*"'
+
"literal_basic": "Line one\nLine two\nLine three\n"
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"folded_basic": "[^"]*"' | head -c 100
+
"folded_basic": "This is a long paragraph that will be folded into a single line with the newlines c
+
+
Verify strip chomping
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"literal_strip": "[^"]*"'
+
"literal_strip": "No trailing newline"
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"folded_strip": "[^"]*"'
+
"folded_strip": "Folded text with stripped trailing newlines"
+
+
Verify clip chomping (single newline)
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"literal_clip": "[^"]*"'
+
"literal_clip": "One trailing newline\n"
+
+
Verify keep chomping (all newlines)
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"literal_keep": "[^"]*"'
+
"literal_keep": "Keeps trailing newlines\n\n\n"
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"folded_keep": "[^"]*"'
+
"folded_keep": "Folded text keeps trailing\n\n\n"
+
+
Verify indentation handling
+
+
$ yamlcat --json ../yaml/scalars_block.yml | grep -o '"literal_indent_2": "[^"]*"'
+
"literal_indent_2": " Two space indentation\n is preserved here\n Extra indent\n Back to two\n"
+
+
Verify nested structures with block scalars
+
+
$ yamlcat ../yaml/scalars_block.yml | tail -10
+
special_chars_folded: "All special chars are literal in block scalars: []{}|>*&\n"
+
sequence_with_blocks:
+
- "First item\nliteral block\n"
+
- "Second item folded block\n"
+
- "Third item\nstripped"
+
- "Fourth item\nkept\n\n\n"
+
nested:
+
description: "This is a folded description that spans multiple lines.\n"
+
code: "def hello():\n print(\"Hello, World!\")\n return True\n"
+
notes: "Final notes\nwith stripped end"
+
+
================================================================================
+
SPECIAL CASES AND EDGE CASES
+
================================================================================
+
+
Empty block scalars
+
+
$ echo 'empty_literal: |' | yamlcat --json
+
{"empty_literal": ""}
+
+
$ echo 'empty_folded: >' | yamlcat --json
+
{"empty_folded": ""}
+
+
Block scalars with special characters (no escaping needed)
+
+
$ echo 'code: |
+
> Special: @#$%^&*()
+
> Quotes: "double" '"'"'single'"'"'
+
> Brackets: [array] {object}' | yamlcat --json
+
{"code": "Special: @#$%^&*()\nQuotes: \"double\" 'single'\nBrackets: [array] {object}\n"}
+
+
Plain scalar vs quoted string for special values
+
+
$ echo 'unquoted_true: true
+
> quoted_true: "true"' | yamlcat --json
+
{"unquoted_true": true, "quoted_true": "true"}
+
+
$ echo 'unquoted_null: null
+
> quoted_null: "null"' | yamlcat --json
+
{"unquoted_null": null, "quoted_null": "null"}
+
+
Strings that need quoting to preserve leading/trailing spaces
+
+
$ echo 'leading: " spaces"
+
> trailing: "spaces "
+
> both: " spaces "' | yamlcat --json
+
{"leading": " spaces", "trailing": "spaces ", "both": " spaces "}
+
+
Block scalars in sequences
+
+
$ echo 'items:
+
> - |
+
> First item
+
> multiline
+
> - >
+
> Second item
+
> folded' | yamlcat --json
+
{"items": ["First item\nmultiline\n", "Second item folded\n"]}
+
+
Block scalars in nested mappings
+
+
$ echo 'outer:
+
> inner:
+
> description: >
+
> This is a folded
+
> description.
+
> code: |
+
> def test():
+
> return True' | yamlcat --json
+
{"outer": {"inner": {"description": "This is a folded description.\n", "code": "def test():\n return True\n"}}}
+
+
Preserving indentation in literal blocks
+
+
$ echo 'code: |
+
> def hello():
+
> print("Hello")
+
> if True:
+
> return 42' | yamlcat --json
+
{"code": "def hello():\n print(\"Hello\")\n if True:\n return 42\n"}
+
+
Folded scalars preserve more-indented lines
+
+
$ echo 'text: >
+
> Normal paragraph
+
> continues here.
+
>
+
> Indented block
+
> preserved.
+
>
+
> Back to normal.' | yamlcat --json
+
{"text": "Normal paragraph continues here.\nIndented block preserved.\nBack to normal.\n"}
+444
yaml/ocaml-yamle/tests/cram/values.t
···
···
+
Test YAML null values from values_null.yml
+
+
$ yamlcat ../yaml/values_null.yml
+
explicit_null: null
+
tilde_null: null
+
empty_null: null
+
flow_null:
+
- null
+
- null
+
- null
+
sequence_nulls:
+
- null
+
- null
+
- null
+
- explicit: null
+
- tilde: null
+
- empty: null
+
mapping_nulls:
+
key1: null
+
key2: null
+
key3: null
+
"null": null key with string value
+
"~": tilde key with string value
+
nested:
+
level1:
+
null_value: null
+
tilde_value: null
+
empty_value: null
+
list:
+
- null
+
- null
+
- null
+
- some_value
+
map:
+
a: null
+
b: null
+
c: null
+
string_nulls:
+
quoted_null: 'null'
+
quoted_tilde: '~'
+
null_in_string: this is null
+
word_null: 'null'
+
+
$ yamlcat --json ../yaml/values_null.yml
+
{"explicit_null": null, "tilde_null": null, "empty_null": null, "flow_null": [null, null, null], "sequence_nulls": [null, null, null, {"explicit": null}, {"tilde": null}, {"empty": null}], "mapping_nulls": {"key1": null, "key2": null, "key3": null}, "null": "null key with string value", "~": "tilde key with string value", "nested": {"level1": {"null_value": null, "tilde_value": null, "empty_value": null, "list": [null, null, null, "some_value"], "map": {"a": null, "b": null, "c": null}}}, "string_nulls": {"quoted_null": "null", "quoted_tilde": "~", "null_in_string": "this is null", "word_null": "null"}}
+
+
Test YAML boolean values from values_bool.yml
+
+
$ yamlcat ../yaml/values_bool.yml
+
bool_true: true
+
bool_false: false
+
capitalized_true: true
+
capitalized_false: false
+
yes_value: true
+
no_value: false
+
Yes_value: true
+
No_value: false
+
YES_value: true
+
NO_value: false
+
on_value: true
+
off_value: false
+
On_value: true
+
Off_value: false
+
ON_value: true
+
OFF_value: false
+
bool_sequence:
+
- true
+
- false
+
- true
+
- false
+
- true
+
- false
+
flow_bools:
+
- true
+
- false
+
- true
+
- false
+
bool_mapping:
+
active: true
+
disabled: false
+
enabled: true
+
stopped: false
+
quoted_bools:
+
quoted_true: 'true'
+
quoted_false: 'false'
+
quoted_yes: 'yes'
+
quoted_no: 'no'
+
single_true: 'true'
+
single_false: 'false'
+
nested_bools:
+
settings:
+
debug: true
+
verbose: false
+
legacy_yes: true
+
legacy_no: false
+
flags:
+
- true
+
- false
+
- true
+
- false
+
mixed_case:
+
"TRUE": true
+
"FALSE": false
+
"TrUe": true
+
"FaLsE": false
+
bool_like_strings:
+
truthy: truely
+
falsy: falsetto
+
yes_sir: yessir
+
no_way: noway
+
+
$ yamlcat --json ../yaml/values_bool.yml
+
{"bool_true": true, "bool_false": false, "capitalized_true": true, "capitalized_false": false, "yes_value": true, "no_value": false, "Yes_value": true, "No_value": false, "YES_value": true, "NO_value": false, "on_value": true, "off_value": false, "On_value": true, "Off_value": false, "ON_value": true, "OFF_value": false, "bool_sequence": [true, false, true, false, true, false], "flow_bools": [true, false, true, false], "bool_mapping": {"active": true, "disabled": false, "enabled": true, "stopped": false}, "quoted_bools": {"quoted_true": "true", "quoted_false": "false", "quoted_yes": "yes", "quoted_no": "no", "single_true": "true", "single_false": "false"}, "nested_bools": {"settings": {"debug": true, "verbose": false, "legacy_yes": true, "legacy_no": false}, "flags": [true, false, true, false]}, "mixed_case": {"TRUE": true, "FALSE": false, "TrUe": true, "FaLsE": false}, "bool_like_strings": {"truthy": "truely", "falsy": "falsetto", "yes_sir": "yessir", "no_way": "noway"}}
+
+
Test YAML number values from values_numbers.yml
+
+
$ yamlcat ../yaml/values_numbers.yml
+
int_zero: 0
+
int_positive: 42
+
int_negative: -17
+
int_large: 1000000
+
int_with_underscores: 1000000
+
octal_value: 12
+
octal_zero: 0
+
octal_large: 511
+
hex_lowercase: 26
+
hex_uppercase: 26
+
hex_mixed: 3735928559
+
hex_zero: 0
+
float_simple: 3.14
+
float_negative: -0.5
+
float_zero: 0
+
float_leading_dot: 0.5
+
float_trailing_zero: 1
+
scientific_positive: 10000000000
+
scientific_negative: 0.0015
+
scientific_uppercase: 250
+
scientific_no_sign: 300000
+
positive_infinity: .inf
+
negative_infinity: -.inf
+
not_a_number: .nan
+
infinity_upper: .inf
+
infinity_caps: .inf
+
nan_upper: .nan
+
nan_caps: .nan
+
number_sequence:
+
- 0
+
- 42
+
- -17
+
- 3.14
+
- 10000000000
+
- .inf
+
- .nan
+
flow_numbers:
+
- 0
+
- 42
+
- -17
+
- 3.14
+
- 26
+
- 12
+
number_mapping:
+
count: 100
+
price: 19.99
+
discount: -5
+
hex_color: 16734003
+
octal_perms: 493
+
scientific: 6.022e+23
+
quoted_numbers:
+
string_int: '42'
+
string_float: '3.14'
+
string_hex: '0x1A'
+
string_octal: 0o14
+
string_inf: '.inf'
+
string_nan: '.nan'
+
numeric_strings:
+
phone: 555-1234
+
version: 1.2.3
+
code: 123
+
leading_zero: 7
+
plus_sign: 123
+
edge_cases:
+
min_int: -9.22337e+18
+
max_int: 9.22337e+18
+
very_small: 1e-100
+
very_large: 1e+100
+
negative_zero: -0
+
positive_zero: 0
+
nested_numbers:
+
coordinates:
+
x: 10.5
+
y: -20.3
+
z: 0
+
measurements:
+
- 1.1
+
- 2.2
+
- 3.3
+
stats:
+
count: 1000
+
average: 45.67
+
max: .inf
+
min: -.inf
+
legacy_octal: 14
+
binary_like: 10
+
format_tests:
+
no_decimal: 42
+
with_decimal: 42
+
leading_zero_decimal: 0.42
+
no_leading_digit: 0.42
+
trailing_decimal: 42
+
+
$ yamlcat --json ../yaml/values_numbers.yml
+
{"int_zero": 0, "int_positive": 42, "int_negative": -17, "int_large": 1000000, "int_with_underscores": 1000000, "octal_value": 12, "octal_zero": 0, "octal_large": 511, "hex_lowercase": 26, "hex_uppercase": 26, "hex_mixed": 3735928559, "hex_zero": 0, "float_simple": 3.14, "float_negative": -0.5, "float_zero": 0, "float_leading_dot": 0.5, "float_trailing_zero": 1, "scientific_positive": 10000000000, "scientific_negative": 0.0015, "scientific_uppercase": 250, "scientific_no_sign": 300000, "positive_infinity": inf, "negative_infinity": -inf, "not_a_number": nan, "infinity_upper": inf, "infinity_caps": inf, "nan_upper": nan, "nan_caps": nan, "number_sequence": [0, 42, -17, 3.14, 10000000000, inf, nan], "flow_numbers": [0, 42, -17, 3.14, 26, 12], "number_mapping": {"count": 100, "price": 19.99, "discount": -5, "hex_color": 16734003, "octal_perms": 493, "scientific": 6.022e+23}, "quoted_numbers": {"string_int": "42", "string_float": "3.14", "string_hex": "0x1A", "string_octal": "0o14", "string_inf": ".inf", "string_nan": ".nan"}, "numeric_strings": {"phone": "555-1234", "version": "1.2.3", "code": 123, "leading_zero": 7, "plus_sign": 123}, "edge_cases": {"min_int": -9.22337e+18, "max_int": 9.22337e+18, "very_small": 1e-100, "very_large": 1e+100, "negative_zero": -0, "positive_zero": 0}, "nested_numbers": {"coordinates": {"x": 10.5, "y": -20.3, "z": 0}, "measurements": [1.1, 2.2, 3.3], "stats": {"count": 1000, "average": 45.67, "max": inf, "min": -inf}}, "legacy_octal": 14, "binary_like": 10, "format_tests": {"no_decimal": 42, "with_decimal": 42, "leading_zero_decimal": 0.42, "no_leading_digit": 0.42, "trailing_decimal": 42}}
+
+
Test YAML timestamp values from values_timestamps.yml
+
+
$ yamlcat ../yaml/values_timestamps.yml
+
date_simple: 2001-12-15
+
date_earliest: 1970-01-01
+
date_leap_year: 2020-02-29
+
date_current: 2025-12-04
+
datetime_utc: '2001-12-15T02:59:43.1Z'
+
datetime_utc_full: '2001-12-15T02:59:43.123456Z'
+
datetime_utc_no_frac: '2001-12-15T02:59:43Z'
+
datetime_offset_pos: '2001-12-15T02:59:43.1+05:30'
+
datetime_offset_neg: '2001-12-15T02:59:43.1-05:00'
+
datetime_offset_hours: '2001-12-15T02:59:43+05'
+
datetime_spaced: '2001-12-14 21:59:43.10 -5'
+
datetime_spaced_utc: '2001-12-15 02:59:43.1 Z'
+
datetime_spaced_offset: '2001-12-14 21:59:43.10 -05:00'
+
datetime_no_frac: '2001-12-15T14:30:00Z'
+
date_only: 2001-12-15
+
timestamp_formats:
+
iso_date: 2001-12-15
+
iso_datetime_z: '2001-12-15T02:59:43Z'
+
iso_datetime_offset: '2001-12-15T02:59:43+00:00'
+
spaced_datetime: '2001-12-14 21:59:43.10 -5'
+
canonical: '2001-12-15T02:59:43.1Z'
+
timestamp_sequence:
+
- 2001-12-15
+
- '2001-12-15T02:59:43.1Z'
+
- '2001-12-14 21:59:43.10 -5'
+
- '2025-01-01T00:00:00Z'
+
events:
+
created: '2001-12-15T02:59:43.1Z'
+
modified: '2001-12-16T10:30:00Z'
+
published: '2001-12-14 21:59:43.10 -5'
+
quoted_timestamps:
+
string_date: 2001-12-15
+
string_datetime: '2001-12-15T02:59:43.1Z'
+
string_spaced: '2001-12-14 21:59:43.10 -5'
+
edge_cases:
+
midnight: '2001-12-15T00:00:00Z'
+
end_of_day: '2001-12-15T23:59:59Z'
+
microseconds: '2001-12-15T02:59:43.123456Z'
+
no_seconds: '2001-12-15T02:59Z'
+
hour_only: 2001-12-15T02Z
+
nested_timestamps:
+
project:
+
start_date: 2001-12-15
+
milestones:
+
- date: 2001-12-20
+
time: '2001-12-20T14:00:00Z'
+
- date: 2002-01-15
+
time: '2002-01-15T09:30:00-05:00'
+
metadata:
+
created: '2001-12-14 21:59:43.10 -5'
+
updated: '2001-12-15T02:59:43.1Z'
+
invalid_timestamps:
+
bad_date: 2001-13-45
+
bad_time: '2001-12-15T25:99:99Z'
+
incomplete: 2001-12
+
no_leading_zero: 2001-1-5
+
timezones:
+
utc_z: '2001-12-15T02:59:43Z'
+
utc_offset: '2001-12-15T02:59:43+00:00'
+
est: '2001-12-14T21:59:43-05:00'
+
ist: '2001-12-15T08:29:43+05:30'
+
jst: '2001-12-15T11:59:43+09:00'
+
date_range:
+
past: 1900-01-01
+
unix_epoch: '1970-01-01T00:00:00Z'
+
y2k: '2000-01-01T00:00:00Z'
+
present: 2025-12-04
+
future: '2099-12-31T23:59:59Z'
+
+
$ yamlcat --json ../yaml/values_timestamps.yml
+
{"date_simple": "2001-12-15", "date_earliest": "1970-01-01", "date_leap_year": "2020-02-29", "date_current": "2025-12-04", "datetime_utc": "2001-12-15T02:59:43.1Z", "datetime_utc_full": "2001-12-15T02:59:43.123456Z", "datetime_utc_no_frac": "2001-12-15T02:59:43Z", "datetime_offset_pos": "2001-12-15T02:59:43.1+05:30", "datetime_offset_neg": "2001-12-15T02:59:43.1-05:00", "datetime_offset_hours": "2001-12-15T02:59:43+05", "datetime_spaced": "2001-12-14 21:59:43.10 -5", "datetime_spaced_utc": "2001-12-15 02:59:43.1 Z", "datetime_spaced_offset": "2001-12-14 21:59:43.10 -05:00", "datetime_no_frac": "2001-12-15T14:30:00Z", "date_only": "2001-12-15", "timestamp_formats": {"iso_date": "2001-12-15", "iso_datetime_z": "2001-12-15T02:59:43Z", "iso_datetime_offset": "2001-12-15T02:59:43+00:00", "spaced_datetime": "2001-12-14 21:59:43.10 -5", "canonical": "2001-12-15T02:59:43.1Z"}, "timestamp_sequence": ["2001-12-15", "2001-12-15T02:59:43.1Z", "2001-12-14 21:59:43.10 -5", "2025-01-01T00:00:00Z"], "events": {"created": "2001-12-15T02:59:43.1Z", "modified": "2001-12-16T10:30:00Z", "published": "2001-12-14 21:59:43.10 -5"}, "quoted_timestamps": {"string_date": "2001-12-15", "string_datetime": "2001-12-15T02:59:43.1Z", "string_spaced": "2001-12-14 21:59:43.10 -5"}, "edge_cases": {"midnight": "2001-12-15T00:00:00Z", "end_of_day": "2001-12-15T23:59:59Z", "microseconds": "2001-12-15T02:59:43.123456Z", "no_seconds": "2001-12-15T02:59Z", "hour_only": "2001-12-15T02Z"}, "nested_timestamps": {"project": {"start_date": "2001-12-15", "milestones": [{"date": "2001-12-20", "time": "2001-12-20T14:00:00Z"}, {"date": "2002-01-15", "time": "2002-01-15T09:30:00-05:00"}], "metadata": {"created": "2001-12-14 21:59:43.10 -5", "updated": "2001-12-15T02:59:43.1Z"}}}, "invalid_timestamps": {"bad_date": "2001-13-45", "bad_time": "2001-12-15T25:99:99Z", "incomplete": "2001-12", "no_leading_zero": "2001-1-5"}, "timezones": {"utc_z": "2001-12-15T02:59:43Z", "utc_offset": "2001-12-15T02:59:43+00:00", "est": "2001-12-14T21:59:43-05:00", "ist": "2001-12-15T08:29:43+05:30", "jst": "2001-12-15T11:59:43+09:00"}, "date_range": {"past": "1900-01-01", "unix_epoch": "1970-01-01T00:00:00Z", "y2k": "2000-01-01T00:00:00Z", "present": "2025-12-04", "future": "2099-12-31T23:59:59Z"}}
+
+
Test inline null values
+
+
$ echo 'explicit: null' | yamlcat --json
+
{"explicit": null}
+
+
$ echo 'tilde: ~' | yamlcat --json
+
{"tilde": null}
+
+
$ echo 'empty:' | yamlcat --json
+
{"empty": null}
+
+
$ echo '[null, ~, ]' | yamlcat --json
+
[null, null, null]
+
+
Test inline boolean values
+
+
$ echo 'bool: true' | yamlcat --json
+
{"bool": true}
+
+
$ echo 'bool: false' | yamlcat --json
+
{"bool": false}
+
+
$ echo '[true, false]' | yamlcat --json
+
[true, false]
+
+
Test inline integer values
+
+
$ echo 'positive: 42' | yamlcat --json
+
{"positive": 42}
+
+
$ echo 'negative: -17' | yamlcat --json
+
{"negative": -17}
+
+
$ echo 'zero: 0' | yamlcat --json
+
{"zero": 0}
+
+
$ echo '[0, 42, -17]' | yamlcat --json
+
[0, 42, -17]
+
+
Test inline float values
+
+
$ echo 'simple: 3.14' | yamlcat --json
+
{"simple": 3.14}
+
+
$ echo 'negative: -0.5' | yamlcat --json
+
{"negative": -0.5}
+
+
$ echo 'leading_dot: .5' | yamlcat --json
+
{"leading_dot": 0.5}
+
+
$ echo '[3.14, -0.5, 0.0]' | yamlcat --json
+
[3.14, -0.5, 0]
+
+
Test scientific notation
+
+
$ echo 'positive_exp: 1.5e10' | yamlcat --json
+
{"positive_exp": 15000000000}
+
+
$ echo 'negative_exp: 1.5e-3' | yamlcat --json
+
{"negative_exp": 0.0015}
+
+
$ echo 'uppercase: 2.5E+2' | yamlcat --json
+
{"uppercase": 250}
+
+
Test special float values
+
+
$ echo 'pos_inf: .inf' | yamlcat --json
+
{"pos_inf": inf}
+
+
$ echo 'neg_inf: -.inf' | yamlcat --json
+
{"neg_inf": -inf}
+
+
$ echo 'not_a_num: .nan' | yamlcat --json
+
{"not_a_num": nan}
+
+
$ echo '[.inf, -.inf, .nan]' | yamlcat --json
+
[inf, -inf, nan]
+
+
Test hexadecimal numbers
+
+
$ echo 'hex_lower: 0x1a' | yamlcat --json
+
{"hex_lower": 26}
+
+
$ echo 'hex_upper: 0x1A' | yamlcat --json
+
{"hex_upper": 26}
+
+
$ echo 'hex_mixed: 0xDeadBeef' | yamlcat --json
+
{"hex_mixed": 3735928559}
+
+
Test octal numbers
+
+
$ echo 'octal: 0o17' | yamlcat --json
+
{"octal": 15}
+
+
$ echo 'octal_zero: 0o0' | yamlcat --json
+
{"octal_zero": 0}
+
+
$ echo 'octal_large: 0o755' | yamlcat --json
+
{"octal_large": 493}
+
+
Test mixed special values
+
+
$ echo 'null: null
+
> bool: true
+
> int: 42
+
> float: 3.14
+
> sci: 1.5e10' | yamlcat --json
+
{"null": null, "bool": true, "int": 42, "float": 3.14, "sci": 15000000000}
+
+
Test quoted vs unquoted special values
+
+
$ echo 'unquoted_null: null
+
> quoted_null: "null"' | yamlcat --json
+
{"unquoted_null": null, "quoted_null": "null"}
+
+
$ echo 'unquoted_bool: true
+
> quoted_bool: "true"' | yamlcat --json
+
{"unquoted_bool": true, "quoted_bool": "true"}
+
+
$ echo 'unquoted_num: 42
+
> quoted_num: "42"' | yamlcat --json
+
{"unquoted_num": 42, "quoted_num": "42"}
+
+
Test edge case numbers
+
+
$ echo 'positive_zero: +0.0' | yamlcat --json
+
{"positive_zero": 0}
+
+
$ echo 'negative_zero: -0.0' | yamlcat --json
+
{"negative_zero": -0}
+
+
$ echo 'very_large: 1.0e100' | yamlcat --json
+
{"very_large": 1e+100}
+
+
$ echo 'very_small: 1.0e-100' | yamlcat --json
+
{"very_small": 1e-100}
+
+
Test YAML 1.2 boolean strictness (only true/false are booleans)
+
+
$ echo 'yes: yes' | yamlcat --json
+
{"yes": true}
+
+
$ echo 'no: no' | yamlcat --json
+
{"no": false}
+
+
$ echo 'on: on' | yamlcat --json
+
{"on": true}
+
+
$ echo 'off: off' | yamlcat --json
+
{"off": false}
+
+
$ echo 'True: True' | yamlcat --json
+
{"True": true}
+
+
$ echo 'FALSE: FALSE' | yamlcat --json
+
{"FALSE": false}