Pure OCaml Yaml 1.2 reader and writer using Bytesrw

break out cram tests to avoid echo

+130 -99
+1
tests/cram/anchor_flow_map.yml
··· 1 + {original: &cfg {a: 1}, copy: *cfg}
+1
tests/cram/anchor_flow_seq.yml
··· 1 + [&item apple, *item]
+4
tests/cram/anchor_list.yml
··· 1 + list: &items 2 + - one 3 + - two 4 + copy: *items
+4
tests/cram/anchor_mapping.yml
··· 1 + person: &p 2 + name: Alice 3 + age: 30 4 + copy: *p
+4
tests/cram/anchor_multiple_refs.yml
··· 1 + value: &v 100 2 + first: *v 3 + second: *v 4 + third: *v
+2
tests/cram/anchor_number.yml
··· 1 + original: &num 42 2 + copy: *num
+2
tests/cram/anchor_simple.yml
··· 1 + anchor: &anc value 2 + alias: *anc
+7 -18
tests/cram/anchors.t
··· 5 5 6 6 Test: Simple scalar anchor and alias 7 7 8 - $ echo 'anchor: &anc value 9 - > alias: *anc' | yamlcat 2>&1 8 + $ yamlcat anchor_simple.yml 2>&1 10 9 anchor: value 11 10 alias: value 12 11 13 12 Test: Numeric anchor and alias 14 13 15 - $ echo 'original: &num 42 16 - > copy: *num' | yamlcat 2>&1 14 + $ yamlcat anchor_number.yml 2>&1 17 15 original: 42 18 16 copy: 42 19 17 20 18 Test: Sequence anchor and alias 21 19 22 - $ echo 'list: &items 23 - > - one 24 - > - two 25 - > copy: *items' | yamlcat 2>&1 20 + $ yamlcat anchor_list.yml 2>&1 26 21 list: 27 22 - one 28 23 - two ··· 32 27 33 28 Test: Mapping anchor and alias 34 29 35 - $ echo 'person: &p 36 - > name: Alice 37 - > age: 30 38 - > copy: *p' | yamlcat 2>&1 30 + $ yamlcat anchor_mapping.yml 2>&1 39 31 person: 40 32 name: Alice 41 33 age: 30 ··· 45 37 46 38 Test: Multiple aliases to same anchor 47 39 48 - $ echo 'value: &v 100 49 - > first: *v 50 - > second: *v 51 - > third: *v' | yamlcat 2>&1 40 + $ yamlcat anchor_multiple_refs.yml 2>&1 52 41 value: 100 53 42 first: 100 54 43 second: 100 ··· 56 45 57 46 Test: Anchor in flow context 58 47 59 - $ echo '[&item apple, *item]' | yamlcat 2>&1 48 + $ yamlcat anchor_flow_seq.yml 2>&1 60 49 - apple 61 50 - apple 62 51 63 52 Test: Anchor with mapping in flow 64 53 65 - $ echo '{original: &cfg {a: 1}, copy: *cfg}' | yamlcat 2>&1 54 + $ yamlcat anchor_flow_map.yml 2>&1 66 55 original: 67 56 a: 1 68 57 copy:
+4
tests/cram/directive_with_comment.yml
··· 1 + %YAML 1.2 2 + # Comment after directive 3 + --- 4 + key: value
+2
tests/cram/directive_without_start.yml
··· 1 + %YAML 1.2 2 + simple: document
+4
tests/cram/doc_with_comments.yml
··· 1 + # This is a comment 2 + name: Alice 3 + # Another comment 4 + value: 42
+4
tests/cram/doc_with_end.yml
··· 1 + --- 2 + title: Example 3 + content: data 4 + ...
+10 -34
tests/cram/documents.t
··· 102 102 Test 9: Inline - implicit document (no markers) 103 103 ==================================== 104 104 105 - $ echo 'name: John 106 - > age: 30 107 - > city: New York' | yamlcat 105 + $ yamlcat person_john.yml 108 106 name: John 109 107 age: 30 110 108 city: New York ··· 112 110 Test 10: Inline - explicit start marker 113 111 ==================================== 114 112 115 - $ echo '--- 116 - > name: Jane 117 - > age: 25' | yamlcat 113 + $ yamlcat person_jane.yml 118 114 name: Jane 119 115 age: 25 120 116 121 117 Test 11: Inline - explicit start and end markers 122 118 ==================================== 123 119 124 - $ echo '--- 125 - > title: Example 126 - > content: data 127 - > ...' | yamlcat 120 + $ yamlcat doc_with_end.yml 128 121 title: Example 129 122 content: data 130 123 131 124 Test 12: Inline - document with %YAML 1.2 directive 132 125 ==================================== 133 126 134 - $ echo '%YAML 1.2 135 - > --- 136 - > version: 1.2 137 - > enabled: true' | yamlcat 127 + $ yamlcat yaml12_version.yml 138 128 version: 1.2 139 129 enabled: true 140 130 141 131 Test 13: Inline - document with comment before content 142 132 ==================================== 143 133 144 - $ echo '# This is a comment 145 - > name: Alice 146 - > # Another comment 147 - > value: 42' | yamlcat 134 + $ yamlcat doc_with_comments.yml 148 135 name: Alice 149 136 value: 42 150 137 151 138 Test 14: Inline - document with comment after directive 152 139 ==================================== 153 140 154 - $ echo '%YAML 1.2 155 - > # Comment after directive 156 - > --- 157 - > key: value' | yamlcat 141 + $ yamlcat directive_with_comment.yml 158 142 key: value 159 143 160 144 Test 15: Inline - explicit markers with comments 161 145 ==================================== 162 146 163 - $ echo '--- # Document start 164 - > data: content 165 - > # Mid-document comment 166 - > more: values 167 - > ... # Document end' | yamlcat 147 + $ yamlcat start_with_comment.yml 168 148 data: content 169 149 more: values 170 150 ··· 183 163 Test 18: Empty document with explicit markers 184 164 ==================================== 185 165 186 - $ echo '--- 187 - > ...' | yamlcat 166 + $ yamlcat empty_doc_markers.yml 188 167 null 189 168 190 169 Test 19: Document with only whitespace and markers 191 170 ==================================== 192 171 193 - $ echo '--- 194 - > 195 - > ...' | yamlcat 172 + $ yamlcat empty_doc_with_blank.yml 196 173 null 197 174 198 175 Test 20: Directive followed by content without explicit start 199 176 ==================================== 200 177 201 - $ echo '%YAML 1.2 202 - > simple: document' | yamlcat 178 + $ yamlcat directive_without_start.yml 203 179 Error: expected document start '---' at line 2, columns 1-1 204 180 [1]
+2
tests/cram/empty_both.yml
··· 1 + empty_seq: [] 2 + empty_map: {}
+6 -14
tests/cram/empty_collections.t
··· 5 5 6 6 Test: Empty sequence 7 7 8 - $ echo 'empty_seq: []' | yamlcat 8 + $ yamlcat empty_seq.yml 9 9 empty_seq: [] 10 10 11 11 Test: Empty mapping 12 12 13 - $ echo 'empty_map: {}' | yamlcat 13 + $ yamlcat empty_map.yml 14 14 empty_map: {} 15 15 16 16 Test: Multiple empty collections 17 17 18 - $ echo 'seq: [] 19 - > map: {} 20 - > data: value' | yamlcat 18 + $ yamlcat multiple_empty.yml 21 19 seq: [] 22 20 map: {} 23 21 data: value 24 22 25 23 Test: Nested empty collections 26 24 27 - $ echo 'outer: 28 - > inner_seq: [] 29 - > inner_map: {}' | yamlcat 25 + $ yamlcat nested_empty.yml 30 26 outer: 31 27 inner_seq: [] 32 28 inner_map: {} 33 29 34 30 Test: Empty collection in sequence 35 31 36 - $ echo 'items: 37 - > - first 38 - > - [] 39 - > - third' | yamlcat 32 + $ yamlcat empty_in_seq.yml 40 33 items: 41 34 - first 42 35 - [] ··· 44 37 45 38 Test: Verify JSON output is correct (for comparison) 46 39 47 - $ echo 'empty_seq: [] 48 - > empty_map: {}' | yamlcat --json 40 + $ yamlcat --json empty_both.yml 49 41 {"empty_seq": [], "empty_map": {}}
+2
tests/cram/empty_doc_markers.yml
··· 1 + --- 2 + ...
+3
tests/cram/empty_doc_with_blank.yml
··· 1 + --- 2 + 3 + ...
+4
tests/cram/empty_in_seq.yml
··· 1 + items: 2 + - first 3 + - [] 4 + - third
+1
tests/cram/empty_map.yml
··· 1 + empty_map: {}
+1
tests/cram/empty_seq.yml
··· 1 + empty_seq: []
+3
tests/cram/folded_block.yml
··· 1 + text: > 2 + line one 3 + line two
+3
tests/cram/fruits_list.yml
··· 1 + - apple 2 + - banana 3 + - cherry
+3
tests/cram/fruits_mapping.yml
··· 1 + fruits: 2 + - apple 3 + - banana
+4
tests/cram/hobbies.yml
··· 1 + name: Alice 2 + hobbies: 3 + - reading 4 + - coding
+3
tests/cram/literal_block.yml
··· 1 + text: | 2 + line one 3 + line two
+3
tests/cram/multiple_empty.yml
··· 1 + seq: [] 2 + map: {} 3 + data: value
+3
tests/cram/nested_empty.yml
··· 1 + outer: 2 + inner_seq: [] 3 + inner_map: {}
+5
tests/cram/nested_mappings.yml
··· 1 + server: 2 + host: localhost 3 + port: 8080 4 + database: 5 + name: mydb
+2
tests/cram/person.yml
··· 1 + name: Alice 2 + age: 30
+3
tests/cram/person_jane.yml
··· 1 + --- 2 + name: Jane 3 + age: 25
+3
tests/cram/person_john.yml
··· 1 + name: John 2 + age: 30 3 + city: New York
+2
tests/cram/quoted_strings.yml
··· 1 + single: 'hello world' 2 + double: "hello world"
+1
tests/cram/simple_hello.yml
··· 1 + hello: world
+5
tests/cram/special_values.yml
··· 1 + null_val: null 2 + bool_true: true 3 + bool_false: false 4 + number: 42 5 + float: 3.14
+4
tests/cram/start_with_comment.yml
··· 1 + --- # Document start 2 + data: content 3 + # Mid-document comment 4 + more: values
+4
tests/cram/yaml12_version.yml
··· 1 + %YAML 1.2 2 + --- 3 + version: 1.2 4 + enabled: true
+11 -33
tests/cram/yamlcat.t
··· 1 1 Test yamlcat with simple YAML 2 2 3 - $ echo 'hello: world' | yamlcat 3 + $ yamlcat simple_hello.yml 4 4 hello: world 5 5 6 - $ echo 'name: Alice 7 - > age: 30' | yamlcat 6 + $ yamlcat person.yml 8 7 name: Alice 9 8 age: 30 10 9 11 10 Test nested mappings 12 11 13 - $ echo 'server: 14 - > host: localhost 15 - > port: 8080 16 - > database: 17 - > name: mydb' | yamlcat 12 + $ yamlcat nested_mappings.yml 18 13 server: 19 14 host: localhost 20 15 port: 8080 ··· 23 18 24 19 Test sequences 25 20 26 - $ echo '- apple 27 - > - banana 28 - > - cherry' | yamlcat 21 + $ yamlcat fruits_list.yml 29 22 - apple 30 23 - banana 31 24 - cherry 32 25 33 26 Test mapping with sequence value 34 27 35 - $ echo 'fruits: 36 - > - apple 37 - > - banana' | yamlcat 28 + $ yamlcat fruits_mapping.yml 38 29 fruits: 39 30 - apple 40 31 - banana 41 32 42 33 Test flow style output 43 34 44 - $ echo 'name: Alice 45 - > hobbies: 46 - > - reading 47 - > - coding' | yamlcat --flow 35 + $ yamlcat --flow hobbies.yml 48 36 {name: Alice, hobbies: [reading, coding]} 49 37 50 38 Test JSON output 51 39 52 - $ echo 'name: Alice 53 - > age: 30' | yamlcat --json 40 + $ yamlcat --json person.yml 54 41 {"name": "Alice", "age": 30} 55 42 56 43 Test seq.yml file (multiline plain scalar) ··· 98 85 99 86 Test special values 100 87 101 - $ echo 'null_val: null 102 - > bool_true: true 103 - > bool_false: false 104 - > number: 42 105 - > float: 3.14' | yamlcat --json 88 + $ yamlcat --json special_values.yml 106 89 {"null_val": null, "bool_true": true, "bool_false": false, "number": 42, "float": 3.14} 107 90 108 91 Test quoted strings 109 92 110 - $ echo 'single: '"'"'hello world'"'"' 111 - > double: "hello world"' | yamlcat 93 + $ yamlcat quoted_strings.yml 112 94 single: hello world 113 95 double: hello world 114 96 115 97 Test literal block scalar 116 98 117 - $ echo 'text: | 118 - > line one 119 - > line two' | yamlcat --json 99 + $ yamlcat --json literal_block.yml 120 100 {"text": "line one\nline two\n"} 121 101 122 102 Test folded block scalar 123 103 124 - $ echo 'text: > 125 - > line one 126 - > line two' | yamlcat --json 104 + $ yamlcat --json folded_block.yml 127 105 {"text": "line one line two\n"} 128 106 129 107 Test linuxkit.yml (sequences of mappings)