this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

features

+988 -332
+49 -47
yaml/ocaml-yamle/bin/yamlcat.ml
··· 35 35 json_to_string buf v; 36 36 Buffer.contents buf 37 37 38 - let process_string ~format ~all ~resolve_aliases ~max_nodes ~max_depth content = 38 + let process_string ~format ~resolve_aliases ~max_nodes ~max_depth content = 39 39 try 40 - if all then 41 - (* Multi-document mode *) 42 - match format with 43 - | Yaml -> 44 - let documents = Yamle.documents_of_string content in 45 - print_string (Yamle.documents_to_string documents) 46 - | Flow -> 47 - let documents = Yamle.documents_of_string content in 48 - print_string (Yamle.documents_to_string ~layout_style:Yamle.Layout_style.Flow documents) 49 - | Json -> 50 - let documents = Yamle.documents_of_string content in 51 - let first = ref true in 52 - List.iter (fun doc -> 53 - match Yamle.Document.root doc with 54 - | None -> () 55 - | Some yaml -> 56 - if not !first then print_endline "---"; 57 - first := false; 58 - let value = Yamle.to_json ~resolve_aliases ~max_nodes ~max_depth yaml in 59 - print_endline (value_to_json value) 60 - ) documents 61 - | Debug -> 62 - let documents = Yamle.documents_of_string content in 63 - List.iteri (fun i doc -> 64 - Format.printf "Document %d:@." (i + 1); 65 - Format.printf "%a@." Yamle.Document.pp doc 66 - ) documents 67 - else 68 - (* Single-document mode (original behavior) *) 69 - match format with 70 - | Yaml -> 71 - let value = Yamle.of_string ~resolve_aliases ~max_nodes ~max_depth content in 72 - print_string (Yamle.to_string value) 73 - | Flow -> 74 - let value = Yamle.of_string ~resolve_aliases ~max_nodes ~max_depth content in 75 - print_string (Yamle.to_string ~layout_style:Yamle.Layout_style.Flow value) 76 - | Json -> 77 - let value = Yamle.of_string ~resolve_aliases ~max_nodes ~max_depth content in 78 - print_endline (value_to_json value) 79 - | Debug -> 80 - let yaml = Yamle.yaml_of_string ~resolve_aliases ~max_nodes ~max_depth content in 81 - Format.printf "%a@." Yamle.pp_yaml yaml 40 + (* Always parse as multi-document stream *) 41 + let documents = Yamle.documents_of_string content in 42 + 43 + match format with 44 + | Yaml -> 45 + (* Convert through Value to apply tag-based type coercion *) 46 + let first = ref true in 47 + List.iter (fun doc -> 48 + if not !first then print_string "---\n"; 49 + first := false; 50 + match Yamle.Document.root doc with 51 + | None -> print_endline "" 52 + | Some yaml -> 53 + let value = Yamle.to_json ~resolve_aliases ~max_nodes ~max_depth yaml in 54 + print_string (Yamle.to_string value) 55 + ) documents 56 + | Flow -> 57 + (* Convert through Value to apply tag-based type coercion *) 58 + let first = ref true in 59 + List.iter (fun doc -> 60 + if not !first then print_string "---\n"; 61 + first := false; 62 + match Yamle.Document.root doc with 63 + | None -> print_endline "" 64 + | Some yaml -> 65 + let value = Yamle.to_json ~resolve_aliases ~max_nodes ~max_depth yaml in 66 + print_string (Yamle.to_string ~layout_style:Yamle.Layout_style.Flow value) 67 + ) documents 68 + | Json -> 69 + let first = ref true in 70 + List.iter (fun doc -> 71 + match Yamle.Document.root doc with 72 + | None -> () 73 + | Some yaml -> 74 + if not !first then print_endline "---"; 75 + first := false; 76 + let value = Yamle.to_json ~resolve_aliases ~max_nodes ~max_depth yaml in 77 + print_endline (value_to_json value) 78 + ) documents 79 + | Debug -> 80 + List.iteri (fun i doc -> 81 + Format.printf "Document %d:@." (i + 1); 82 + Format.printf "%a@." Yamle.Document.pp doc 83 + ) documents 82 84 with 83 85 | Yamle.Yamle_error e -> 84 86 Printf.eprintf "Error: %s\n" (Yamle.Error.to_string e); 85 87 exit 1 86 88 87 - let process_file ~format ~all ~resolve_aliases ~max_nodes ~max_depth filename = 89 + let process_file ~format ~resolve_aliases ~max_nodes ~max_depth filename = 88 90 let content = 89 91 if filename = "-" then 90 92 In_channel.input_all In_channel.stdin 91 93 else 92 94 In_channel.with_open_text filename In_channel.input_all 93 95 in 94 - process_string ~format ~all ~resolve_aliases ~max_nodes ~max_depth content 96 + process_string ~format ~resolve_aliases ~max_nodes ~max_depth content 95 97 96 - let run format all resolve_aliases max_nodes max_depth files = 98 + let run format _all resolve_aliases max_nodes max_depth files = 97 99 let files = if files = [] then ["-"] else files in 98 - List.iter (process_file ~format ~all ~resolve_aliases ~max_nodes ~max_depth) files; 100 + List.iter (process_file ~format ~resolve_aliases ~max_nodes ~max_depth) files; 99 101 `Ok () 100 102 101 103 (* Command-line arguments *)
+34 -4
yaml/ocaml-yamle/lib/emitter.ml
··· 698 698 emit t (Event.Document_end { implicit = true }); 699 699 emit t Event.Stream_end 700 700 701 - let emit_document t doc = 701 + (** Strip anchors from a YAML tree *) 702 + let rec strip_anchors (yaml : Yaml.t) : Yaml.t = 703 + match yaml with 704 + | `Scalar s -> 705 + if Scalar.anchor s = None then yaml 706 + else 707 + `Scalar (Scalar.make 708 + ?tag:(Scalar.tag s) 709 + ~plain_implicit:(Scalar.plain_implicit s) 710 + ~quoted_implicit:(Scalar.quoted_implicit s) 711 + ~style:(Scalar.style s) 712 + (Scalar.value s)) 713 + | `Alias _ -> yaml 714 + | `A seq -> 715 + `A (Sequence.make 716 + ?tag:(Sequence.tag seq) 717 + ~implicit:(Sequence.implicit seq) 718 + ~style:(Sequence.style seq) 719 + (List.map strip_anchors (Sequence.members seq))) 720 + | `O map -> 721 + `O (Mapping.make 722 + ?tag:(Mapping.tag map) 723 + ~implicit:(Mapping.implicit map) 724 + ~style:(Mapping.style map) 725 + (List.map (fun (k, v) -> (strip_anchors k, strip_anchors v)) (Mapping.members map))) 726 + 727 + let emit_document ?(resolve_aliases = true) t doc = 702 728 emit t (Event.Document_start { 703 729 version = Document.version doc; 704 730 implicit = Document.implicit_start doc; 705 731 }); 706 732 (match Document.root doc with 707 - | Some yaml -> emit_yaml_node t yaml 733 + | Some yaml -> 734 + let yaml = if resolve_aliases then 735 + yaml |> Yaml.resolve_aliases |> strip_anchors 736 + else yaml in 737 + emit_yaml_node t yaml 708 738 | None -> 709 739 emit t (Event.Scalar { 710 740 anchor = None; tag = None; ··· 726 756 emit_yaml t yaml; 727 757 contents t 728 758 729 - let documents_to_string ?(config = default_config) documents = 759 + let documents_to_string ?(config = default_config) ?(resolve_aliases = true) documents = 730 760 let t = create ~config () in 731 761 emit t (Event.Stream_start { encoding = config.encoding }); 732 - List.iter (emit_document t) documents; 762 + List.iter (emit_document ~resolve_aliases t) documents; 733 763 emit t Event.Stream_end; 734 764 contents t
+2 -1
yaml/ocaml-yamle/lib/yamle.ml
··· 71 71 ?(encoding = Encoding.Utf8) 72 72 ?(scalar_style = Scalar_style.Any) 73 73 ?(layout_style = Layout_style.Any) 74 + ?(resolve_aliases = true) 74 75 documents = 75 76 let config = { 76 77 Emitter.default_config with ··· 78 79 scalar_style; 79 80 layout_style; 80 81 } in 81 - Emitter.documents_to_string ~config documents 82 + Emitter.documents_to_string ~config ~resolve_aliases documents 82 83 83 84 (** {1 Conversion} *) 84 85
+375
yaml/ocaml-yamle/tests/cram/anchors.t
··· 1 + Anchor and Alias Support (currently not supported) 2 + 3 + These tests document anchor (&) and alias (*) support that is not yet 4 + implemented. Currently, aliases fail with "unresolved alias" error. 5 + 6 + Test: Simple scalar anchor and alias 7 + 8 + $ echo 'anchor: &anc value 9 + > alias: *anc' | yamlcat 2>&1 10 + anchor: value 11 + alias: value 12 + 13 + Test: Numeric anchor and alias 14 + 15 + $ echo 'original: &num 42 16 + > copy: *num' | yamlcat 2>&1 17 + original: 42 18 + copy: 42 19 + 20 + Test: Sequence anchor and alias 21 + 22 + $ echo 'list: &items 23 + > - one 24 + > - two 25 + > copy: *items' | yamlcat 2>&1 26 + list: 27 + - one 28 + - two 29 + copy: 30 + - one 31 + - two 32 + 33 + Test: Mapping anchor and alias 34 + 35 + $ echo 'person: &p 36 + > name: Alice 37 + > age: 30 38 + > copy: *p' | yamlcat 2>&1 39 + person: 40 + name: Alice 41 + age: 30 42 + copy: 43 + name: Alice 44 + age: 30 45 + 46 + Test: Multiple aliases to same anchor 47 + 48 + $ echo 'value: &v 100 49 + > first: *v 50 + > second: *v 51 + > third: *v' | yamlcat 2>&1 52 + value: 100 53 + first: 100 54 + second: 100 55 + third: 100 56 + 57 + Test: Anchor in flow context 58 + 59 + $ echo '[&item apple, *item]' | yamlcat 2>&1 60 + - apple 61 + - apple 62 + 63 + Test: Anchor with mapping in flow 64 + 65 + $ echo '{original: &cfg {a: 1}, copy: *cfg}' | yamlcat 2>&1 66 + original: 67 + a: 1 68 + copy: 69 + a: 1 70 + 71 + Test: Anchors file from test suite 72 + 73 + $ yamlcat ../yaml/anchors_basic.yml 2>&1 74 + scalar_anchor: Hello, World! 75 + scalar_alias: Hello, World! 76 + --- 77 + original: 42 78 + copy: 42 79 + another_copy: 42 80 + --- 81 + original_list: 82 + - apple 83 + - banana 84 + - cherry 85 + copied_list: 86 + - apple 87 + - banana 88 + - cherry 89 + --- 90 + original_map: 91 + name: Alice 92 + age: 30 93 + city: London 94 + copied_map: 95 + name: Alice 96 + age: 30 97 + city: London 98 + --- 99 + defaults: 100 + timeout: 30 101 + retries: 3 102 + colors: 103 + - red 104 + - green 105 + - blue 106 + config: 107 + settings: 108 + timeout: 30 109 + retries: 3 110 + palette: 111 + - red 112 + - green 113 + - blue 114 + --- 115 + template: 116 + metadata: 117 + version: 1 118 + author: John Doe 119 + settings: 120 + enabled: true 121 + debug: false 122 + instance1: 123 + metadata: 124 + version: 1 125 + author: John Doe 126 + settings: 127 + enabled: true 128 + debug: false 129 + instance2: 130 + metadata: 131 + version: 1 132 + author: John Doe 133 + settings: 134 + enabled: true 135 + debug: false 136 + --- 137 + items: 138 + - id: 1 139 + name: First 140 + - id: 2 141 + name: Second 142 + - id: 1 143 + name: First 144 + --- 145 + shared_value: 100 146 + calculations: 147 + base: 100 148 + doubled: 200 149 + reference: 100 150 + another_ref: 100 151 + --- 152 + feature_flag: true 153 + features: 154 + login: true 155 + signup: true 156 + export: true 157 + --- 158 + empty: null 159 + values: 160 + first: null 161 + second: null 162 + --- 163 + message: "This is a multi-line\nmessage with some\nspecial content!\n" 164 + output1: "This is a multi-line\nmessage with some\nspecial content!\n" 165 + output2: "This is a multi-line\nmessage with some\nspecial content!\n" 166 + --- 167 + database: 168 + primary: 169 + host: localhost 170 + port: 5432 171 + ssl: true 172 + replica: 173 + host: localhost 174 + port: 5432 175 + ssl: true 176 + backup: 177 + host: localhost 178 + port: 5432 179 + ssl: true 180 + 181 + $ yamlcat ../yaml/anchors_merge.yml 2>&1 182 + defaults: 183 + timeout: 30 184 + retries: 3 185 + verbose: false 186 + production: 187 + <<: 188 + timeout: 30 189 + retries: 3 190 + verbose: false 191 + environment: production 192 + --- 193 + base: 194 + color: red 195 + size: medium 196 + weight: 100 197 + custom: 198 + <<: 199 + color: red 200 + size: medium 201 + weight: 100 202 + color: blue 203 + shape: circle 204 + --- 205 + connection: 206 + host: localhost 207 + port: 8080 208 + authentication: 209 + username: admin 210 + password: secret 211 + server: 212 + <<: 213 + - host: localhost 214 + port: 8080 215 + - username: admin 216 + password: secret 217 + ssl: true 218 + --- 219 + defaults: 220 + timeout: 30 221 + retries: 3 222 + advanced: 223 + cache: true 224 + pool_size: 10 225 + config: 226 + <<: 227 + - timeout: 30 228 + retries: 3 229 + - cache: true 230 + pool_size: 10 231 + timeout: 60 232 + custom: value 233 + --- 234 + base_style: 235 + font: Arial 236 + size: 12 237 + heading_defaults: 238 + <<: 239 + font: Arial 240 + size: 12 241 + weight: bold 242 + main_heading: 243 + <<: 244 + <<: 245 + font: Arial 246 + size: 12 247 + weight: bold 248 + size: 18 249 + color: navy 250 + --- 251 + common: 252 + enabled: true 253 + log_level: info 254 + services: 255 + - name: web 256 + <<: 257 + enabled: true 258 + log_level: info 259 + port: 80 260 + - name: api 261 + <<: 262 + enabled: true 263 + log_level: info 264 + port: 3000 265 + - name: worker 266 + <<: 267 + enabled: true 268 + log_level: info 269 + threads: 4 270 + --- 271 + empty: {} 272 + config: 273 + <<: {} 274 + key: value 275 + --- 276 + metadata: 277 + created: 2023-01-01 278 + author: Admin 279 + tags: 280 + - v1 281 + - stable 282 + document: 283 + <<: 284 + created: 2023-01-01 285 + author: Admin 286 + tags: 287 + - v1 288 + - stable 289 + title: Important Document 290 + content: Some content here 291 + --- 292 + level1: 293 + a: 1 294 + b: 2 295 + level2: 296 + <<: 297 + a: 1 298 + b: 2 299 + c: 3 300 + level3: 301 + <<: 302 + <<: 303 + a: 1 304 + b: 2 305 + c: 3 306 + d: 4 307 + --- 308 + first: 309 + name: First 310 + value: 100 311 + priority: low 312 + second: 313 + name: Second 314 + value: 200 315 + category: important 316 + combined: 317 + <<: 318 + - name: First 319 + value: 100 320 + priority: low 321 + - name: Second 322 + value: 200 323 + category: important 324 + name: Combined 325 + --- 326 + numbers: 327 + count: 42 328 + ratio: 3.14 329 + active: true 330 + derived: 331 + <<: 332 + count: 42 333 + ratio: 3.14 334 + active: true 335 + label: Test 336 + --- 337 + db_defaults: 338 + pool_size: 5 339 + timeout: 30 340 + ssl: false 341 + cache_defaults: 342 + ttl: 3600 343 + max_size: 1000 344 + development: 345 + database: 346 + <<: 347 + pool_size: 5 348 + timeout: 30 349 + ssl: false 350 + host: localhost 351 + name: dev_db 352 + cache: 353 + <<: 354 + ttl: 3600 355 + max_size: 1000 356 + backend: memory 357 + production: 358 + database: 359 + <<: 360 + pool_size: 5 361 + timeout: 30 362 + ssl: false 363 + host: prod.example.com 364 + name: prod_db 365 + ssl: true 366 + pool_size: 20 367 + cache: 368 + <<: 369 + ttl: 3600 370 + max_size: 1000 371 + backend: redis 372 + ttl: 7200 373 + 374 + Note: The anchor test files also use multiple documents, so they fail 375 + with multi-document errors before even hitting anchor issues.
+12 -6
yaml/ocaml-yamle/tests/cram/bomb.t
··· 48 48 > EOF 49 49 50 50 $ yamlcat --no-resolve-aliases --debug simple_alias.yml 51 - mapping( 52 - style=block, 53 - members={ 54 - scalar("anchor", style=plain): scalar("hello", anchor=anc, style=plain), 55 - scalar("alias", style=plain): *anc 56 - }) 51 + Document 1: 52 + document( 53 + implicit_start=true, 54 + implicit_end=true, 55 + root=mapping( 56 + style=block, 57 + members={ 58 + scalar("anchor", style=plain): 59 + scalar("hello", anchor=anc, style=plain), 60 + scalar("alias", style=plain): *anc 61 + }) 62 + ) 57 63 58 64 With resolve (default), aliases are expanded: 59 65
+49
yaml/ocaml-yamle/tests/cram/empty.t
··· 1 + Empty Collection YAML Emission 2 + 3 + These tests verify that empty sequences and mappings are correctly emitted 4 + as [] and {} in YAML output. 5 + 6 + Test: Empty sequence 7 + 8 + $ echo 'empty_seq: []' | yamlcat 9 + empty_seq: [] 10 + 11 + Test: Empty mapping 12 + 13 + $ echo 'empty_map: {}' | yamlcat 14 + empty_map: {} 15 + 16 + Test: Multiple empty collections 17 + 18 + $ echo 'seq: [] 19 + > map: {} 20 + > data: value' | yamlcat 21 + seq: [] 22 + map: {} 23 + data: value 24 + 25 + Test: Nested empty collections 26 + 27 + $ echo 'outer: 28 + > inner_seq: [] 29 + > inner_map: {}' | yamlcat 30 + outer: 31 + inner_seq: [] 32 + inner_map: {} 33 + 34 + Test: Empty collection in sequence 35 + 36 + $ echo 'items: 37 + > - first 38 + > - [] 39 + > - third' | yamlcat 40 + items: 41 + - first 42 + - [] 43 + - third 44 + 45 + Test: Verify JSON output is correct (for comparison) 46 + 47 + $ echo 'empty_seq: [] 48 + > empty_map: {}' | yamlcat --json 49 + {"empty_seq": [], "empty_map": {}}
-82
yaml/ocaml-yamle/tests/cram/failing_anchors.t
··· 1 - Anchor and Alias Support (currently not supported) 2 - 3 - These tests document anchor (&) and alias (*) support that is not yet 4 - implemented. Currently, aliases fail with "unresolved alias" error. 5 - 6 - Test: Simple scalar anchor and alias 7 - 8 - $ echo 'anchor: &anc value 9 - > alias: *anc' | yamlcat 2>&1 10 - anchor: value 11 - alias: value 12 - 13 - Test: Numeric anchor and alias 14 - 15 - $ echo 'original: &num 42 16 - > copy: *num' | yamlcat 2>&1 17 - original: 42 18 - copy: 42 19 - 20 - Test: Sequence anchor and alias 21 - 22 - $ echo 'list: &items 23 - > - one 24 - > - two 25 - > copy: *items' | yamlcat 2>&1 26 - list: 27 - - one 28 - - two 29 - copy: 30 - - one 31 - - two 32 - 33 - Test: Mapping anchor and alias 34 - 35 - $ echo 'person: &p 36 - > name: Alice 37 - > age: 30 38 - > copy: *p' | yamlcat 2>&1 39 - person: 40 - name: Alice 41 - age: 30 42 - copy: 43 - name: Alice 44 - age: 30 45 - 46 - Test: Multiple aliases to same anchor 47 - 48 - $ echo 'value: &v 100 49 - > first: *v 50 - > second: *v 51 - > third: *v' | yamlcat 2>&1 52 - value: 100 53 - first: 100 54 - second: 100 55 - third: 100 56 - 57 - Test: Anchor in flow context 58 - 59 - $ echo '[&item apple, *item]' | yamlcat 2>&1 60 - - apple 61 - - apple 62 - 63 - Test: Anchor with mapping in flow 64 - 65 - $ echo '{original: &cfg {a: 1}, copy: *cfg}' | yamlcat 2>&1 66 - original: 67 - a: 1 68 - copy: 69 - a: 1 70 - 71 - Test: Anchors file from test suite 72 - 73 - $ yamlcat ../yaml/anchors_basic.yml 2>&1 74 - Error: multiple documents found when single expected 75 - [1] 76 - 77 - $ yamlcat ../yaml/anchors_merge.yml 2>&1 78 - Error: multiple documents found when single expected 79 - [1] 80 - 81 - Note: The anchor test files also use multiple documents, so they fail 82 - with multi-document errors before even hitting anchor issues.
-56
yaml/ocaml-yamle/tests/cram/failing_empty.t
··· 1 - Empty Collection YAML Emission (currently outputs nothing instead of [] or {}) 2 - 3 - These tests document the empty collection emission issue where empty 4 - sequences and mappings are emitted as nothing (interpreted as null) 5 - instead of [] or {} in YAML output. 6 - 7 - Note: JSON output correctly shows [] and {} for empty collections. 8 - The issue is only with YAML-format output. 9 - 10 - Test: Empty sequence emits as nothing instead of [] 11 - 12 - $ echo 'empty_seq: []' | yamlcat 13 - empty_seq: [] 14 - 15 - The above outputs just "empty_seq:" with nothing after it. 16 - Expected output should be: empty_seq: [] 17 - 18 - Test: Empty mapping emits as nothing instead of {} 19 - 20 - $ echo 'empty_map: {}' | yamlcat 21 - empty_map: {} 22 - 23 - Test: Multiple empty collections 24 - 25 - $ echo 'seq: [] 26 - > map: {} 27 - > data: value' | yamlcat 28 - seq: [] 29 - map: {} 30 - data: value 31 - 32 - Test: Nested empty collections 33 - 34 - $ echo 'outer: 35 - > inner_seq: [] 36 - > inner_map: {}' | yamlcat 37 - outer: 38 - inner_seq: [] 39 - inner_map: {} 40 - 41 - Test: Empty collection in sequence 42 - 43 - $ echo 'items: 44 - > - first 45 - > - [] 46 - > - third' | yamlcat 47 - items: 48 - - first 49 - - [] 50 - - third 51 - 52 - Test: Verify JSON output is correct (for comparison) 53 - 54 - $ echo 'empty_seq: [] 55 - > empty_map: {}' | yamlcat --json 56 - {"empty_seq": [], "empty_map": {}}
-73
yaml/ocaml-yamle/tests/cram/failing_multidoc.t
··· 1 - Multi-document stream support (currently not supported) 2 - 3 - These tests document expected behavior for multi-document YAML streams. 4 - They currently fail with "multiple documents found when single expected". 5 - 6 - Test: Two documents separated by --- 7 - 8 - $ echo '--- 9 - > first: document 10 - > --- 11 - > second: document' | yamlcat 2>&1 12 - Error: multiple documents found when single expected 13 - [1] 14 - 15 - Test: Three documents with different types 16 - 17 - $ echo '--- 18 - > mapping: value 19 - > --- 20 - > - sequence 21 - > - items 22 - > --- 23 - > scalar value' | yamlcat 2>&1 24 - Error: multiple documents found when single expected 25 - [1] 26 - 27 - Test: Documents with explicit end markers 28 - 29 - $ echo '--- 30 - > doc1: value 31 - > ... 32 - > --- 33 - > doc2: value 34 - > ...' | yamlcat 2>&1 35 - Error: multiple documents found when single expected 36 - [1] 37 - 38 - Test: Empty documents 39 - 40 - $ echo '--- 41 - > --- 42 - > content: here 43 - > ---' | yamlcat 2>&1 44 - Error: multiple documents found when single expected 45 - [1] 46 - 47 - Test: Multi-document file 48 - 49 - $ yamlcat ../yaml/documents_multi.yml 2>&1 50 - Error: multiple documents found when single expected 51 - [1] 52 - 53 - $ yamlcat ../yaml/documents_multi_three.yml 2>&1 54 - Error: multiple documents found when single expected 55 - [1] 56 - 57 - $ yamlcat ../yaml/documents_multi_with_end.yml 2>&1 58 - Error: multiple documents found when single expected 59 - [1] 60 - 61 - $ yamlcat ../yaml/documents_multi_empty.yml 2>&1 62 - Error: multiple documents found when single expected 63 - [1] 64 - 65 - Test: Anchors file (uses multiple documents) 66 - 67 - $ yamlcat ../yaml/anchors_basic.yml 2>&1 68 - Error: multiple documents found when single expected 69 - [1] 70 - 71 - $ yamlcat ../yaml/anchors_merge.yml 2>&1 72 - Error: multiple documents found when single expected 73 - [1]
-63
yaml/ocaml-yamle/tests/cram/failing_tags.t
··· 1 - Tag Shorthand Support (currently not supported) 2 - 3 - These tests document YAML tag shorthand (!!) support that is not yet 4 - implemented. Currently, tags are parsed as part of plain scalar content. 5 - 6 - Test: String tag shorthand 7 - 8 - $ echo '!!str 123' | yamlcat 9 - '123' 10 - 11 - Expected: 123 (as a string) 12 - 13 - Test: Integer tag shorthand 14 - 15 - $ echo '!!int "42"' | yamlcat 16 - 42 17 - 18 - Expected: 42 19 - 20 - Test: Boolean tag shorthand 21 - 22 - $ echo '!!bool "yes"' | yamlcat 23 - true 24 - 25 - Expected: true 26 - 27 - Test: Null tag shorthand 28 - 29 - $ echo '!!null ""' | yamlcat 30 - null 31 - 32 - Expected: null 33 - 34 - Test: Float tag shorthand 35 - 36 - $ echo '!!float 3.14' | yamlcat 37 - 3.14 38 - 39 - Expected: 3.14 40 - 41 - Test: Tag shorthand in mapping value 42 - 43 - $ echo 'value: !!str 42' | yamlcat 44 - value: '42' 45 - 46 - Expected: value: "42" (string representation) 47 - 48 - Test: Local tags 49 - 50 - $ echo '!local_tag value' | yamlcat 51 - value 52 - 53 - Expected: value (with local tag applied) 54 - 55 - Test: Verbatim tags 56 - 57 - $ echo '!<tag:example.com:type> value' | yamlcat 58 - value 59 - 60 - Expected: value (with verbatim tag applied) 61 - 62 - Note: Tags are being parsed as literal text in the scalar value, 63 - with exclamation marks escaped in the output.
+407
yaml/ocaml-yamle/tests/cram/multidoc.t
··· 1 + Multi-document stream support (currently not supported) 2 + 3 + These tests document expected behavior for multi-document YAML streams. 4 + They currently fail with "multiple documents found when single expected". 5 + 6 + Test: Two documents separated by --- 7 + 8 + $ echo '--- 9 + > first: document 10 + > --- 11 + > second: document' | yamlcat 2>&1 12 + first: document 13 + --- 14 + second: document 15 + 16 + Test: Three documents with different types 17 + 18 + $ echo '--- 19 + > mapping: value 20 + > --- 21 + > - sequence 22 + > - items 23 + > --- 24 + > scalar value' | yamlcat 2>&1 25 + mapping: value 26 + --- 27 + - sequence 28 + - items 29 + --- 30 + scalar value 31 + 32 + Test: Documents with explicit end markers 33 + 34 + $ echo '--- 35 + > doc1: value 36 + > ... 37 + > --- 38 + > doc2: value 39 + > ...' | yamlcat 2>&1 40 + doc1: value 41 + --- 42 + doc2: value 43 + 44 + Test: Empty documents 45 + 46 + $ echo '--- 47 + > --- 48 + > content: here 49 + > ---' | yamlcat 2>&1 50 + null 51 + --- 52 + content: here 53 + --- 54 + null 55 + 56 + Test: Multi-document file 57 + 58 + $ yamlcat ../yaml/documents_multi.yml 2>&1 59 + document: first 60 + type: mapping 61 + data: 62 + key1: value1 63 + key2: value2 64 + --- 65 + document: second 66 + type: mapping 67 + data: 68 + key3: value3 69 + key4: value4 70 + 71 + $ yamlcat ../yaml/documents_multi_three.yml 2>&1 72 + name: John Doe 73 + age: 30 74 + city: New York 75 + --- 76 + - apple 77 + - banana 78 + - orange 79 + - grape 80 + --- 81 + This is a plain scalar document 82 + 83 + $ yamlcat ../yaml/documents_multi_with_end.yml 2>&1 84 + first: 85 + document: data1 86 + value: 100 87 + --- 88 + second: 89 + document: data2 90 + value: 200 91 + --- 92 + third: 93 + document: data3 94 + value: 300 95 + 96 + $ yamlcat ../yaml/documents_multi_empty.yml 2>&1 97 + null 98 + --- 99 + key: value 100 + --- 101 + null 102 + --- 103 + - item1 104 + - item2 105 + 106 + Test: Anchors file (uses multiple documents) 107 + 108 + $ yamlcat ../yaml/anchors_basic.yml 2>&1 109 + scalar_anchor: Hello, World! 110 + scalar_alias: Hello, World! 111 + --- 112 + original: 42 113 + copy: 42 114 + another_copy: 42 115 + --- 116 + original_list: 117 + - apple 118 + - banana 119 + - cherry 120 + copied_list: 121 + - apple 122 + - banana 123 + - cherry 124 + --- 125 + original_map: 126 + name: Alice 127 + age: 30 128 + city: London 129 + copied_map: 130 + name: Alice 131 + age: 30 132 + city: London 133 + --- 134 + defaults: 135 + timeout: 30 136 + retries: 3 137 + colors: 138 + - red 139 + - green 140 + - blue 141 + config: 142 + settings: 143 + timeout: 30 144 + retries: 3 145 + palette: 146 + - red 147 + - green 148 + - blue 149 + --- 150 + template: 151 + metadata: 152 + version: 1 153 + author: John Doe 154 + settings: 155 + enabled: true 156 + debug: false 157 + instance1: 158 + metadata: 159 + version: 1 160 + author: John Doe 161 + settings: 162 + enabled: true 163 + debug: false 164 + instance2: 165 + metadata: 166 + version: 1 167 + author: John Doe 168 + settings: 169 + enabled: true 170 + debug: false 171 + --- 172 + items: 173 + - id: 1 174 + name: First 175 + - id: 2 176 + name: Second 177 + - id: 1 178 + name: First 179 + --- 180 + shared_value: 100 181 + calculations: 182 + base: 100 183 + doubled: 200 184 + reference: 100 185 + another_ref: 100 186 + --- 187 + feature_flag: true 188 + features: 189 + login: true 190 + signup: true 191 + export: true 192 + --- 193 + empty: null 194 + values: 195 + first: null 196 + second: null 197 + --- 198 + message: "This is a multi-line\nmessage with some\nspecial content!\n" 199 + output1: "This is a multi-line\nmessage with some\nspecial content!\n" 200 + output2: "This is a multi-line\nmessage with some\nspecial content!\n" 201 + --- 202 + database: 203 + primary: 204 + host: localhost 205 + port: 5432 206 + ssl: true 207 + replica: 208 + host: localhost 209 + port: 5432 210 + ssl: true 211 + backup: 212 + host: localhost 213 + port: 5432 214 + ssl: true 215 + 216 + $ yamlcat ../yaml/anchors_merge.yml 2>&1 217 + defaults: 218 + timeout: 30 219 + retries: 3 220 + verbose: false 221 + production: 222 + <<: 223 + timeout: 30 224 + retries: 3 225 + verbose: false 226 + environment: production 227 + --- 228 + base: 229 + color: red 230 + size: medium 231 + weight: 100 232 + custom: 233 + <<: 234 + color: red 235 + size: medium 236 + weight: 100 237 + color: blue 238 + shape: circle 239 + --- 240 + connection: 241 + host: localhost 242 + port: 8080 243 + authentication: 244 + username: admin 245 + password: secret 246 + server: 247 + <<: 248 + - host: localhost 249 + port: 8080 250 + - username: admin 251 + password: secret 252 + ssl: true 253 + --- 254 + defaults: 255 + timeout: 30 256 + retries: 3 257 + advanced: 258 + cache: true 259 + pool_size: 10 260 + config: 261 + <<: 262 + - timeout: 30 263 + retries: 3 264 + - cache: true 265 + pool_size: 10 266 + timeout: 60 267 + custom: value 268 + --- 269 + base_style: 270 + font: Arial 271 + size: 12 272 + heading_defaults: 273 + <<: 274 + font: Arial 275 + size: 12 276 + weight: bold 277 + main_heading: 278 + <<: 279 + <<: 280 + font: Arial 281 + size: 12 282 + weight: bold 283 + size: 18 284 + color: navy 285 + --- 286 + common: 287 + enabled: true 288 + log_level: info 289 + services: 290 + - name: web 291 + <<: 292 + enabled: true 293 + log_level: info 294 + port: 80 295 + - name: api 296 + <<: 297 + enabled: true 298 + log_level: info 299 + port: 3000 300 + - name: worker 301 + <<: 302 + enabled: true 303 + log_level: info 304 + threads: 4 305 + --- 306 + empty: {} 307 + config: 308 + <<: {} 309 + key: value 310 + --- 311 + metadata: 312 + created: 2023-01-01 313 + author: Admin 314 + tags: 315 + - v1 316 + - stable 317 + document: 318 + <<: 319 + created: 2023-01-01 320 + author: Admin 321 + tags: 322 + - v1 323 + - stable 324 + title: Important Document 325 + content: Some content here 326 + --- 327 + level1: 328 + a: 1 329 + b: 2 330 + level2: 331 + <<: 332 + a: 1 333 + b: 2 334 + c: 3 335 + level3: 336 + <<: 337 + <<: 338 + a: 1 339 + b: 2 340 + c: 3 341 + d: 4 342 + --- 343 + first: 344 + name: First 345 + value: 100 346 + priority: low 347 + second: 348 + name: Second 349 + value: 200 350 + category: important 351 + combined: 352 + <<: 353 + - name: First 354 + value: 100 355 + priority: low 356 + - name: Second 357 + value: 200 358 + category: important 359 + name: Combined 360 + --- 361 + numbers: 362 + count: 42 363 + ratio: 3.14 364 + active: true 365 + derived: 366 + <<: 367 + count: 42 368 + ratio: 3.14 369 + active: true 370 + label: Test 371 + --- 372 + db_defaults: 373 + pool_size: 5 374 + timeout: 30 375 + ssl: false 376 + cache_defaults: 377 + ttl: 3600 378 + max_size: 1000 379 + development: 380 + database: 381 + <<: 382 + pool_size: 5 383 + timeout: 30 384 + ssl: false 385 + host: localhost 386 + name: dev_db 387 + cache: 388 + <<: 389 + ttl: 3600 390 + max_size: 1000 391 + backend: memory 392 + production: 393 + database: 394 + <<: 395 + pool_size: 5 396 + timeout: 30 397 + ssl: false 398 + host: prod.example.com 399 + name: prod_db 400 + ssl: true 401 + pool_size: 20 402 + cache: 403 + <<: 404 + ttl: 3600 405 + max_size: 1000 406 + backend: redis 407 + ttl: 7200
+60
yaml/ocaml-yamle/tests/cram/tags.t
··· 1 + Tag Support Tests 2 + 3 + These tests verify YAML tag support including type coercion and 4 + different tag formats. 5 + 6 + Test: String tag shorthand 7 + 8 + $ printf '!!str 123' | yamlcat 9 + '123' 10 + 11 + The !!str tag forces the value to be treated as a string. 12 + 13 + Test: Integer tag shorthand 14 + 15 + $ printf '!!int "42"' | yamlcat 16 + 42 17 + 18 + The !!int tag coerces the quoted string to an integer. 19 + 20 + Test: Boolean tag shorthand 21 + 22 + $ printf '!!bool "yes"' | yamlcat 23 + true 24 + 25 + The !!bool tag coerces the string to a boolean. 26 + 27 + Test: Null tag shorthand 28 + 29 + $ printf '!!null ""' | yamlcat 30 + null 31 + 32 + The !!null tag coerces the value to null. 33 + 34 + Test: Float tag shorthand 35 + 36 + $ printf '!!float 3.14' | yamlcat 37 + 3.14 38 + 39 + The !!float tag specifies a floating-point number. 40 + 41 + Test: Tag shorthand in mapping value 42 + 43 + $ printf 'value: !!str 42' | yamlcat 44 + value: '42' 45 + 46 + Tags work in mapping values and force type coercion. 47 + 48 + Test: Local tags 49 + 50 + $ printf '!local_tag value' | yamlcat 51 + value 52 + 53 + Local tags (single !) are treated as unknown and default to string type. 54 + 55 + Test: Verbatim tags 56 + 57 + $ printf '!<tag:example.com:type> value' | yamlcat 58 + value 59 + 60 + Verbatim tags (!<...>) are treated as unknown and default to string type.