···11+(* Categorize test failures *)
22+open Yamle
33+module TL = Test_suite_lib.Test_suite_loader
44+module TF = Test_suite_lib.Tree_format
55+66+let test_suite_path = "../yaml-test-suite"
77+88+let normalize_tree s =
99+ let lines = String.split_on_char '\n' s in
1010+ let lines = List.filter (fun l -> String.trim l <> "") lines in
1111+ String.concat "\n" lines
1212+1313+type failure =
1414+ | Error_not_detected of string
1515+ | Parse_error of string
1616+ | Tree_mismatch of string * string
1717+1818+let run_test (test : TL.test_case) =
1919+ if test.fail then begin
2020+ try
2121+ let parser = Parser.of_string test.yaml in
2222+ let _events = Parser.to_list parser in
2323+ Some (Error_not_detected test.name)
2424+ with _ -> None
2525+ end
2626+ else begin
2727+ match test.tree with
2828+ | None -> None
2929+ | Some expected ->
3030+ try
3131+ let parser = Parser.of_string test.yaml in
3232+ let events = Parser.to_list parser in
3333+ let actual = TF.of_spanned_events events in
3434+ let expected_norm = normalize_tree expected in
3535+ let actual_norm = normalize_tree actual in
3636+ if expected_norm = actual_norm then None
3737+ else Some (Tree_mismatch (expected_norm, actual_norm))
3838+ with e ->
3939+ let msg = Printexc.to_string e in
4040+ Some (Parse_error msg)
4141+ end
4242+4343+let diff_lines expected actual =
4444+ let exp_lines = String.split_on_char '\n' expected in
4545+ let act_lines = String.split_on_char '\n' actual in
4646+ let rec find_diff i es as_ =
4747+ match es, as_ with
4848+ | [], [] -> None
4949+ | [], _ -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines))
5050+ | _, [] -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines))
5151+ | e :: es', a :: as_' ->
5252+ if e = a then find_diff (i + 1) es' as_'
5353+ else Some (Printf.sprintf "Line %d differs:\n exp: %s\n got: %s" i e a)
5454+ in
5555+ find_diff 1 exp_lines act_lines
5656+5757+let () =
5858+ let src_path = Filename.concat test_suite_path "src" in
5959+ let all_tests = TL.load_directory src_path in
6060+6161+ let error_not_detected = ref [] in
6262+ let parse_errors = ref [] in
6363+ let tree_mismatches = ref [] in
6464+6565+ List.iter (fun test ->
6666+ match run_test test with
6767+ | None -> ()
6868+ | Some (Error_not_detected name) ->
6969+ error_not_detected := (test.TL.id, name) :: !error_not_detected
7070+ | Some (Parse_error msg) ->
7171+ parse_errors := (test.TL.id, test.TL.name, msg) :: !parse_errors
7272+ | Some (Tree_mismatch (exp, act)) ->
7373+ tree_mismatches := (test.TL.id, test.TL.name, exp, act) :: !tree_mismatches
7474+ ) all_tests;
7575+7676+ Printf.printf "=== ERROR TESTS NOT DETECTED (%d) ===\n" (List.length !error_not_detected);
7777+ List.iter (fun (id, name) ->
7878+ Printf.printf " %s: %s\n" id name
7979+ ) (List.rev !error_not_detected);
8080+8181+ Printf.printf "\n=== PARSE ERRORS (%d) ===\n" (List.length !parse_errors);
8282+ List.iter (fun (id, name, msg) ->
8383+ Printf.printf " %s: %s\n %s\n" id name msg
8484+ ) (List.rev !parse_errors);
8585+8686+ Printf.printf "\n=== TREE MISMATCHES (%d) ===\n" (List.length !tree_mismatches);
8787+ List.iter (fun (id, name, exp, act) ->
8888+ let diff = diff_lines exp act in
8989+ Printf.printf " %s: %s\n" id name;
9090+ match diff with
9191+ | Some d -> Printf.printf " %s\n" d
9292+ | None -> ()
9393+ ) (List.rev !tree_mismatches)
+12
yaml/ocaml-yamle/tests/count_tests.ml
···11+module TL = Test_suite_lib.Test_suite_loader
22+33+let () =
44+ let tests = TL.load_directory "../yaml-test-suite/src" in
55+ let error_without_tree = List.filter (fun t -> t.TL.fail && t.TL.tree = None) tests in
66+ let non_error_without_tree = List.filter (fun t -> (not t.TL.fail) && t.TL.tree = None) tests in
77+ Printf.printf "Error tests without tree: %d\n" (List.length error_without_tree);
88+ Printf.printf "Non-error tests without tree (will be skipped): %d\n" (List.length non_error_without_tree);
99+ Printf.printf "\nError tests without tree:\n";
1010+ List.iter (fun t -> Printf.printf " %s\n" t.TL.id) error_without_tree;
1111+ Printf.printf "\nNon-error tests without tree:\n";
1212+ List.iter (fun t -> Printf.printf " %s\n" t.TL.id) non_error_without_tree
+71
yaml/ocaml-yamle/tests/debug_5we3_6m2f.ml
···11+open Yamle
22+33+let show_token tok =
44+ Format.asprintf "%a" Token.pp_spanned tok
55+66+let show_event evt =
77+ Format.asprintf "%a" Event.pp_spanned evt
88+99+let test_5we3 () =
1010+ Printf.printf "\n=== Test 5WE3: Explicit Block Mapping Entries ===\n";
1111+ let yaml = "? explicit key # Empty value\n? |\n block key\n: - one # Explicit compact\n - two # block value" in
1212+ Printf.printf "Input:\n%s\n\n" yaml;
1313+ try
1414+ let scanner = Scanner.of_string yaml in
1515+ Printf.printf "Tokens:\n";
1616+ let rec print_tokens () =
1717+ match Scanner.peek scanner with
1818+ | None -> Printf.printf "No more tokens\n"
1919+ | Some tok ->
2020+ Printf.printf " %s\n" (show_token tok);
2121+ ignore (Scanner.next scanner);
2222+ print_tokens ()
2323+ in
2424+ print_tokens ();
2525+ Printf.printf "\nParsing:\n";
2626+ let scanner = Scanner.of_string yaml in
2727+ let parser = Parser.create scanner in
2828+ let rec print_events () =
2929+ match Parser.next parser with
3030+ | None -> Printf.printf "No more events\n"
3131+ | Some event ->
3232+ Printf.printf " %s\n" (show_event event);
3333+ print_events ()
3434+ in
3535+ print_events ()
3636+ with e ->
3737+ Printf.printf "ERROR: %s\n" (Printexc.to_string e)
3838+3939+let test_6m2f () =
4040+ Printf.printf "\n=== Test 6M2F: Aliases in Explicit Block Mapping ===\n";
4141+ let yaml = "? &a a\n: &b b\n: *a" in
4242+ Printf.printf "Input:\n%s\n\n" yaml;
4343+ try
4444+ let scanner = Scanner.of_string yaml in
4545+ Printf.printf "Tokens:\n";
4646+ let rec print_tokens () =
4747+ match Scanner.peek scanner with
4848+ | None -> Printf.printf "No more tokens\n"
4949+ | Some tok ->
5050+ Printf.printf " %s\n" (show_token tok);
5151+ ignore (Scanner.next scanner);
5252+ print_tokens ()
5353+ in
5454+ print_tokens ();
5555+ Printf.printf "\nParsing:\n";
5656+ let scanner = Scanner.of_string yaml in
5757+ let parser = Parser.create scanner in
5858+ let rec print_events () =
5959+ match Parser.next parser with
6060+ | None -> Printf.printf "No more events\n"
6161+ | Some event ->
6262+ Printf.printf " %s\n" (show_event event);
6363+ print_events ()
6464+ in
6565+ print_events ()
6666+ with e ->
6767+ Printf.printf "ERROR: %s\n" (Printexc.to_string e)
6868+6969+let () =
7070+ test_5we3 ();
7171+ test_6m2f ()
+62
yaml/ocaml-yamle/tests/debug_block_issues.ml
···11+open Yamle
22+open Test_suite_lib
33+44+let test_case name yaml expected_tree =
55+ Printf.printf "\n=== Testing %s ===\n" name;
66+ Printf.printf "YAML:\n%s\n" yaml;
77+ Printf.printf "\nExpected tree:\n%s\n" expected_tree;
88+99+ try
1010+ let input = Input.of_string yaml in
1111+ let scanner = Scanner.create input in
1212+ let parser = Parser.create scanner in
1313+1414+ (* Skip token output for now *)
1515+ ();
1616+1717+ Printf.printf "\nParsing...\n";
1818+ let rec collect_events acc =
1919+ match Parser.next parser with
2020+ | None -> List.rev acc
2121+ | Some evt -> collect_events (evt :: acc)
2222+ in
2323+ let events = collect_events [] in
2424+2525+ let tree = Tree_format.of_spanned_events events in
2626+ Printf.printf "\nFormatted tree:\n%s\n" tree;
2727+2828+ if tree = expected_tree then
2929+ Printf.printf "✓ PASS\n"
3030+ else
3131+ Printf.printf "✗ FAIL - Tree mismatch\n"
3232+ with
3333+ | Error.Yamle_error err ->
3434+ Printf.printf "ERROR: %s\n" (Error.to_string err)
3535+ | e ->
3636+ Printf.printf "ERROR: %s\n" (Printexc.to_string e)
3737+3838+let () =
3939+ (* JEF9 - Extra newlines at end *)
4040+ test_case "JEF9"
4141+ "- |+\n\n"
4242+ "+STR\n +DOC\n +SEQ\n =VAL |\\n\\n\n -SEQ\n -DOC\n-STR";
4343+4444+ (* K858 - Empty scalar chomping - block scalar consuming too much *)
4545+ test_case "K858"
4646+ "strip: >-\n\nclip: >\n\nkeep: |+\n\n"
4747+ "+STR\n +DOC\n +MAP\n =VAL :strip\n =VAL >\n =VAL :clip\n =VAL >\n =VAL :keep\n =VAL |\\n\n -MAP\n -DOC\n-STR";
4848+4949+ (* L24T - Trailing whitespace-only line *)
5050+ test_case "L24T"
5151+ "foo: |\n x\n \n"
5252+ "+STR\n +DOC\n +MAP\n =VAL :foo\n =VAL |x\\n \\n\n -MAP\n -DOC\n-STR";
5353+5454+ (* MJS9 - Folded block newline handling *)
5555+ test_case "MJS9"
5656+ ">\n foo \n \n \t bar\n\n baz\n"
5757+ "+STR\n +DOC\n =VAL >foo \\n\\n\\t bar\\n\\nbaz\\n\n -DOC\n-STR";
5858+5959+ (* R4YG - Tab handling in folded block - just the problematic 4th test *)
6060+ test_case "R4YG-4"
6161+ "- >\n \t\n detected\n"
6262+ "+STR\n +DOC\n +SEQ\n =VAL >\\t\\ndetected\\n\n -SEQ\n -DOC\n-STR"
···11+(* Debug PRH3 specifically *)
22+open Yamle
33+44+let yaml = "' 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty '"
55+66+let () =
77+ Printf.printf "Input YAML:\n";
88+ for i = 0 to String.length yaml - 1 do
99+ let c = yaml.[i] in
1010+ match c with
1111+ | '\n' -> Printf.printf "\\n"
1212+ | '\t' -> Printf.printf "\\t"
1313+ | ' ' -> Printf.printf "·"
1414+ | _ -> Printf.printf "%c" c
1515+ done;
1616+ Printf.printf "\n\n";
1717+1818+ Printf.printf "Expected: ' 1st non-empty\\n2nd non-empty 3rd non-empty '\n";
1919+ Printf.printf "Expected (visual): '·1st·non-empty\\n2nd·non-empty·3rd·non-empty·'\n\n";
2020+2121+ try
2222+ let parser = Parser.of_string yaml in
2323+ let events = Parser.to_list parser in
2424+ List.iter (fun (e : Event.spanned) ->
2525+ match e.event with
2626+ | Event.Scalar { value; _ } ->
2727+ Printf.printf "Actual scalar value:\n";
2828+ for i = 0 to String.length value - 1 do
2929+ let c = value.[i] in
3030+ match c with
3131+ | '\n' -> Printf.printf "\\n"
3232+ | '\t' -> Printf.printf "\\t"
3333+ | ' ' -> Printf.printf "·"
3434+ | _ -> Printf.printf "%c" c
3535+ done;
3636+ Printf.printf "\n";
3737+ Printf.printf "Length: %d\n" (String.length value)
3838+ | _ -> ()
3939+ ) events
4040+ with e ->
4141+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+42
yaml/ocaml-yamle/tests/debug_quoted.ml
···11+(* Debug quoted string issues *)
22+open Yamle
33+module TL = Test_suite_lib.Test_suite_loader
44+module TF = Test_suite_lib.Tree_format
55+66+let test_suite_path = "../yaml-test-suite"
77+88+let () =
99+ let src_path = Filename.concat test_suite_path "src" in
1010+ let all_tests = TL.load_directory src_path in
1111+1212+ (* Filter for specific tests *)
1313+ let tests = List.filter (fun t ->
1414+ t.TL.id = "PRH3" || t.TL.id = "T4YY" || t.TL.id = "NAT4"
1515+ ) all_tests in
1616+1717+ List.iter (fun test ->
1818+ Printf.printf "\n=== %s: %s ===\n" test.TL.id test.TL.name;
1919+ Printf.printf "YAML input:\n%s\n" (String.escaped test.TL.yaml);
2020+ Printf.printf "YAML (raw):\n%s\n---\n" test.TL.yaml;
2121+2222+ match test.TL.tree with
2323+ | None -> Printf.printf "No expected tree\n"
2424+ | Some expected ->
2525+ Printf.printf "Expected tree:\n%s\n" expected;
2626+2727+ (try
2828+ let parser = Parser.of_string test.TL.yaml in
2929+ let events = Parser.to_list parser in
3030+ let actual = TF.of_spanned_events events in
3131+ Printf.printf "Actual tree:\n%s\n" actual;
3232+3333+ (* Show scalar values *)
3434+ List.iter (fun (e : Event.spanned) ->
3535+ match e.event with
3636+ | Event.Scalar { value; _ } ->
3737+ Printf.printf "Scalar value: %s (len=%d)\n" (String.escaped value) (String.length value)
3838+ | _ -> ()
3939+ ) events;
4040+ with e ->
4141+ Printf.printf "Error: %s\n" (Printexc.to_string e))
4242+ ) tests
+23
yaml/ocaml-yamle/tests/debug_r4yg.ml
···11+module TL = Test_suite_lib.Test_suite_loader
22+module TF = Test_suite_lib.Tree_format
33+open Yamle
44+55+let () =
66+ let tests = TL.load_file "../yaml-test-suite/src/R4YG.yaml" in
77+ List.iter (fun (test : TL.test_case) ->
88+ Printf.printf "=== Test: %s ===\n" test.id;
99+ Printf.printf "YAML bytes: ";
1010+ String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml;
1111+ Printf.printf "\n";
1212+ Printf.printf "YAML repr: %S\n" test.yaml;
1313+ Printf.printf "YAML len: %d\n" (String.length test.yaml);
1414+ try
1515+ let parser = Parser.of_string test.yaml in
1616+ let events = Parser.to_list parser in
1717+ Printf.printf "Events: %d\n" (List.length events);
1818+ let tree = TF.of_spanned_events events in
1919+ Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
2020+ Printf.printf "Actual tree:\n%s\n" tree
2121+ with e ->
2222+ Printf.printf "Error: %s\n" (Printexc.to_string e)
2323+ ) tests
+39
yaml/ocaml-yamle/tests/debug_v9d5.ml
···11+open Yamle
22+module TL = Test_suite_lib.Test_suite_loader
33+module TF = Test_suite_lib.Tree_format
44+55+let () =
66+ let tests = TL.load_file "../yaml-test-suite/src/V9D5.yaml" in
77+ List.iter (fun (test : TL.test_case) ->
88+ Printf.printf "=== Test: %s ===\n" test.id;
99+ Printf.printf "YAML: %S\n" test.yaml;
1010+1111+ (* Print tokens *)
1212+ Printf.printf "\nTokens:\n";
1313+ let scanner = Scanner.of_string test.yaml in
1414+ begin try
1515+ let rec loop () =
1616+ match Scanner.next scanner with
1717+ | None -> Printf.printf " (none)\n"
1818+ | Some tok ->
1919+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
2020+ (Format.asprintf "%a" Token.pp tok.token);
2121+ match tok.token with
2222+ | Token.Stream_end -> ()
2323+ | _ -> loop ()
2424+ in
2525+ loop ()
2626+ with e ->
2727+ Printf.printf "Scanner error: %s\n" (Printexc.to_string e)
2828+ end;
2929+3030+ Printf.printf "\nExpected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
3131+ Printf.printf "\nParsing:\n";
3232+ try
3333+ let parser = Parser.of_string test.yaml in
3434+ let events = Parser.to_list parser in
3535+ let tree = TF.of_spanned_events events in
3636+ Printf.printf "Actual tree:\n%s\n" tree
3737+ with e ->
3838+ Printf.printf "Error: %s\n" (Printexc.to_string e)
3939+ ) tests
+13
yaml/ocaml-yamle/tests/debug_y79y_03.ml
···11+open Yamle
22+let () =
33+ (* Y79Y/03: - [<nl><tab>foo,<nl> foo<nl> ] *)
44+ let yaml = "- [\n\tfoo,\n foo\n ]" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let events = Parser.to_list parser in
99+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1010+ List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
1111+ with
1212+ | Yamle_error e ->
1313+ Format.printf "Error (expected): %a@." Error.pp e
+13
yaml/ocaml-yamle/tests/debug_y79y_09.ml
···11+open Yamle
22+let () =
33+ (* Y79Y/09: ? key:<nl>:<tab>key: *)
44+ let yaml = "? key:\n:\tkey:" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let events = Parser.to_list parser in
99+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1010+ List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
1111+ with
1212+ | Yamle_error e ->
1313+ Format.printf "Error (expected): %a@." Error.pp e
+13
yaml/ocaml-yamle/tests/debug_y79y_first.ml
···11+open Yamle
22+let () =
33+ (* Y79Y first test: block scalar followed by tab-only line *)
44+ let yaml = "foo: |\n\t\nbar: 1\n" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let events = Parser.to_list parser in
99+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1010+ List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
1111+ with
1212+ | Yamle_error e ->
1313+ Format.printf "Error (expected): %a@." Error.pp e
+70
yaml/ocaml-yamle/tests/run_all_tests.ml
···11+(* Run all yaml-test-suite tests *)
22+open Yamle
33+module TL = Test_suite_lib.Test_suite_loader
44+module TF = Test_suite_lib.Tree_format
55+66+let test_suite_path = "../yaml-test-suite"
77+88+let normalize_tree s =
99+ let lines = String.split_on_char '\n' s in
1010+ let lines = List.filter (fun l -> String.trim l <> "") lines in
1111+ String.concat "\n" lines
1212+1313+let run_test (test : TL.test_case) =
1414+ if test.fail then begin
1515+ try
1616+ let parser = Parser.of_string test.yaml in
1717+ let _events = Parser.to_list parser in
1818+ `Fail "Expected parsing to fail"
1919+ with
2020+ | Yamle_error _ -> `Pass
2121+ | _ -> `Pass
2222+ end
2323+ else begin
2424+ match test.tree with
2525+ | None -> `Skip
2626+ | Some expected ->
2727+ try
2828+ let parser = Parser.of_string test.yaml in
2929+ let events = Parser.to_list parser in
3030+ let actual = TF.of_spanned_events events in
3131+ let expected_norm = normalize_tree expected in
3232+ let actual_norm = normalize_tree actual in
3333+ if expected_norm = actual_norm then `Pass
3434+ else begin
3535+ let msg = Printf.sprintf "Tree mismatch:\nExpected:\n%s\nActual:\n%s" expected_norm actual_norm in
3636+ `Fail msg
3737+ end
3838+ with e ->
3939+ let msg = Printexc.to_string e in
4040+ `Fail (Printf.sprintf "Exception: %s" msg)
4141+ end
4242+4343+let () =
4444+ let src_path = Filename.concat test_suite_path "src" in
4545+ let all_tests = TL.load_directory src_path in
4646+ Printf.printf "Total tests loaded: %d\n%!" (List.length all_tests);
4747+4848+ let pass = ref 0 in
4949+ let fail = ref 0 in
5050+ let skip = ref 0 in
5151+ let failures = ref [] in
5252+5353+ List.iter (fun test ->
5454+ match run_test test with
5555+ | `Pass -> incr pass
5656+ | `Skip -> incr skip
5757+ | `Fail msg ->
5858+ incr fail;
5959+ failures := (test.TL.id, test.TL.name, msg) :: !failures
6060+ ) all_tests;
6161+6262+ Printf.printf "\nResults: %d pass, %d fail, %d skip (total: %d)\n%!"
6363+ !pass !fail !skip (!pass + !fail + !skip);
6464+6565+ if !fail > 0 then begin
6666+ Printf.printf "\nFailing tests:\n";
6767+ List.iter (fun (id, name, _msg) ->
6868+ Printf.printf " %s: %s\n" id name
6969+ ) (List.rev !failures)
7070+ end
+23
yaml/ocaml-yamle/tests/test_229q_direct.ml
···11+open Yamle
22+33+let () =
44+ let yaml = In_channel.with_open_text "../yaml-test-suite/src/229Q.yaml" In_channel.input_all in
55+ Printf.printf "YAML length: %d\n" (String.length yaml);
66+ Printf.printf "First 200 chars: %S\n" (String.sub yaml 0 (min 200 (String.length yaml)));
77+ let scanner = Scanner.of_string yaml in
88+ Printf.printf "\nTokens:\n";
99+ try
1010+ let rec loop count =
1111+ if count > 30 then Printf.printf " ... (stopped at 30 tokens)\n"
1212+ else match Scanner.next scanner with
1313+ | None -> Printf.printf " (none)\n"
1414+ | Some tok ->
1515+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
1616+ (Format.asprintf "%a" Token.pp tok.token);
1717+ match tok.token with
1818+ | Token.Stream_end -> ()
1919+ | _ -> loop (count + 1)
2020+ in
2121+ loop 0
2222+ with e ->
2323+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+12
yaml/ocaml-yamle/tests/test_2cms.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "this\n is\n invalid: x\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ Printf.printf "\nParsing:\n";
77+ try
88+ let parser = Parser.of_string yaml in
99+ let events = Parser.to_list parser in
1010+ Printf.printf "Events: %d (should have errored)\n" (List.length events)
1111+ with e ->
1212+ Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
+18
yaml/ocaml-yamle/tests/test_2cms_quick.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "this\n is\n invalid: x\n" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ Format.printf "Parsing:@.";
77+ try
88+ let parser = Parser.of_string yaml in
99+ let events = Parser.to_list parser in
1010+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1111+ List.iter (fun e ->
1212+ Format.printf " %a@." Event.pp e.Event.event
1313+ ) events
1414+ with
1515+ | Yamle_error e ->
1616+ Format.printf "Error (expected): %a@." Error.pp e
1717+ | e ->
1818+ Format.printf "Error: %s@." (Printexc.to_string e)
+25
yaml/ocaml-yamle/tests/test_3hfz.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "---\nkey: value\n... invalid\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ Printf.printf "Byte 18: %C (space=%b, break=%b)\n"
77+ yaml.[18]
88+ (yaml.[18] = ' ' || yaml.[18] = '\t')
99+ (yaml.[18] = '\n' || yaml.[18] = '\r');
1010+ let scanner = Scanner.of_string yaml in
1111+ Printf.printf "\nTokens:\n";
1212+ try
1313+ let rec loop () =
1414+ match Scanner.next scanner with
1515+ | None -> Printf.printf " (none)\n"
1616+ | Some tok ->
1717+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
1818+ (Format.asprintf "%a" Token.pp tok.token);
1919+ match tok.token with
2020+ | Token.Stream_end -> ()
2121+ | _ -> loop ()
2222+ in
2323+ loop ()
2424+ with e ->
2525+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+29
yaml/ocaml-yamle/tests/test_565n_debug.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "generic: !!binary |
55+ R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
66+ OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
77+ +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
88+ AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" in
99+1010+ let scanner = Scanner.of_string yaml in
1111+ let rec find_binary () =
1212+ match Scanner.next scanner with
1313+ | None -> None
1414+ | Some { token; _ } ->
1515+ match token with
1616+ | Token.Scalar { style = Scalar_style.Literal; value; _ } -> Some value
1717+ | _ -> find_binary ()
1818+ in
1919+ match find_binary () with
2020+ | None -> Printf.printf "No literal scalar found\n"
2121+ | Some value ->
2222+ Printf.printf "Got: %S\n" value;
2323+ Printf.printf "First char: %C (code %d)\n" value.[0] (Char.code value.[0]);
2424+ if value.[0] = ' ' then
2525+ Printf.printf "FAIL: starts with space\n"
2626+ else if value.[0] = 'R' then
2727+ Printf.printf "PASS: starts with R\n"
2828+ else
2929+ Printf.printf "FAIL: starts with unexpected char\n"
+17
yaml/ocaml-yamle/tests/test_5llu_quick.ml
···11+open Yamle
22+(* Test 5LLU: Block scalar with wrong indented line after spaces only *)
33+let () =
44+ (* block scalar: >
55+ ␣ (1 space, empty line)
66+ ␣␣ (2 spaces, empty line)
77+ ␣␣␣ (3 spaces, empty line)
88+ invalid (1 space + content - ERROR!) *)
99+ let yaml = "block scalar: >\n \n \n \n invalid\n" in
1010+ Format.printf "YAML: %S@.@." yaml;
1111+ try
1212+ let parser = Parser.of_string yaml in
1313+ let events = Parser.to_list parser in
1414+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events)
1515+ with
1616+ | Yamle_error e ->
1717+ Format.printf "Error (expected): %a@." Error.pp e
+11
yaml/ocaml-yamle/tests/test_5u3a.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "key: - a\n - b\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let events = Parser.to_list parser in
99+ Printf.printf "Events: %d (should have errored)\n" (List.length events)
1010+ with e ->
1111+ Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
+29
yaml/ocaml-yamle/tests/test_6vjk_debug.ml
···11+open Yamle
22+33+let () =
44+ let yaml = ">
55+ Sammy Sosa completed another
66+ fine season with great stats.
77+88+ 63 Home Runs
99+ 0.288 Batting Average
1010+1111+ What a year!" in
1212+ Printf.printf "Input YAML:\n%s\n\n" yaml;
1313+1414+ (* Create scanner and get scalar token *)
1515+ let scanner = Scanner.of_string yaml in
1616+ let rec find_scalar () =
1717+ match Scanner.next scanner with
1818+ | None -> failwith "No scalar found"
1919+ | Some { token; _ } ->
2020+ match token with
2121+ | Token.Scalar (style, value) ->
2222+ Printf.printf "Scalar value: %S\n" value;
2323+ Printf.printf "Style: %s\n" (match style with
2424+ | Scalar_style.Literal -> "Literal"
2525+ | Scalar_style.Folded -> "Folded"
2626+ | _ -> "Other")
2727+ | _ -> find_scalar ()
2828+ in
2929+ find_scalar ()
+31
yaml/ocaml-yamle/tests/test_6vjk_only.ml
···11+open Yamle
22+33+let () =
44+ let yaml = ">
55+ Sammy Sosa completed another
66+ fine season with great stats.
77+88+ 63 Home Runs
99+ 0.288 Batting Average
1010+1111+ What a year!" in
1212+1313+ let scanner = Scanner.of_string yaml in
1414+ let rec find_scalar () =
1515+ match Scanner.next scanner with
1616+ | None -> None
1717+ | Some { token; _ } ->
1818+ match token with
1919+ | Token.Scalar { style = _; value } -> Some value
2020+ | _ -> find_scalar ()
2121+ in
2222+ match find_scalar () with
2323+ | None -> Printf.printf "No scalar found\n"
2424+ | Some value ->
2525+ Printf.printf "Got: %S\n" value;
2626+ let expected = "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" in
2727+ Printf.printf "Expected: %S\n" expected;
2828+ if value = expected then
2929+ Printf.printf "PASS\n"
3030+ else
3131+ Printf.printf "FAIL\n"
···11+open Yamle
22+33+let test name yaml =
44+ Printf.printf "\n=== %s ===\n" name;
55+ let scanner = Scanner.of_string yaml in
66+ try
77+ while Scanner.next scanner <> None do () done;
88+ Printf.printf "PASS\n"
99+ with e ->
1010+ Printf.printf "FAIL: %s\n" (Printexc.to_string e)
1111+1212+let () =
1313+ (* All cases mentioned in the issue *)
1414+ test "565N - Construct Binary" "generic: !!binary |\n R0lGODlh";
1515+ test "A984 - Multiline Scalar" "a: b\n c\nd:\n e\n f";
1616+ test "RZP5 - Trailing Comments" "- #lala\n seq2";
1717+ test "XW4D - Trailing Comments variant" "- #comment\n value";
1818+ test "Q9WF - Separation Spaces" "a: -\tb";
1919+ test "V9D5 - Compact Block Mappings" "- a: b"
+167
yaml/ocaml-yamle/tests/test_anchor_tag_issues.ml
···11+(** Test cases for BU8L, SKE5, RZP5, XW4D *)
22+33+let print_token tok =
44+ match tok.Yamle.Token.token with
55+ | Yamle.Token.Stream_start _ -> "Stream_start"
66+ | Yamle.Token.Stream_end -> "Stream_end"
77+ | Yamle.Token.Document_start -> "Document_start"
88+ | Yamle.Token.Document_end -> "Document_end"
99+ | Yamle.Token.Block_sequence_start -> "Block_sequence_start"
1010+ | Yamle.Token.Block_mapping_start -> "Block_mapping_start"
1111+ | Yamle.Token.Block_end -> "Block_end"
1212+ | Yamle.Token.Flow_sequence_start -> "Flow_sequence_start"
1313+ | Yamle.Token.Flow_sequence_end -> "Flow_sequence_end"
1414+ | Yamle.Token.Flow_mapping_start -> "Flow_mapping_start"
1515+ | Yamle.Token.Flow_mapping_end -> "Flow_mapping_end"
1616+ | Yamle.Token.Block_entry -> "Block_entry"
1717+ | Yamle.Token.Flow_entry -> "Flow_entry"
1818+ | Yamle.Token.Key -> "Key"
1919+ | Yamle.Token.Value -> "Value"
2020+ | Yamle.Token.Alias name -> "Alias(" ^ name ^ ")"
2121+ | Yamle.Token.Anchor name -> "Anchor(" ^ name ^ ")"
2222+ | Yamle.Token.Tag { handle; suffix } -> "Tag(" ^ handle ^ suffix ^ ")"
2323+ | Yamle.Token.Scalar { value; _ } -> "Scalar(" ^ String.sub value 0 (min 20 (String.length value)) ^ ")"
2424+ | Yamle.Token.Version_directive _ -> "Version_directive"
2525+ | Yamle.Token.Tag_directive _ -> "Tag_directive"
2626+2727+let test_bu8l () =
2828+ print_endline "Testing BU8L: Node Anchor and Tag on Separate Lines";
2929+ let yaml = {|key: &anchor
3030+ !!map
3131+ a: b|} in
3232+ try
3333+ let scanner = Yamle.Scanner.of_string yaml in
3434+ let rec print_tokens n =
3535+ if n > 30 then (print_endline " ... (stopped at 30 tokens)"; ())
3636+ else
3737+ try
3838+ match Yamle.Scanner.peek scanner with
3939+ | Some { token = Stream_end; _ } as tok ->
4040+ Printf.printf " %s\n" (print_token (Option.get tok));
4141+ ignore (Yamle.Scanner.next scanner);
4242+ ()
4343+ | Some tok ->
4444+ Printf.printf " %s\n" (print_token tok);
4545+ ignore (Yamle.Scanner.next scanner);
4646+ print_tokens (n + 1)
4747+ | None -> print_endline " (no more tokens)"
4848+ with
4949+ | Yamle.Error.Yamle_error e ->
5050+ Printf.printf " ERROR during scan: %s\n" (Yamle.Error.to_string e);
5151+ raise (Yamle.Error.Yamle_error e)
5252+ in
5353+ print_tokens 0;
5454+ print_endline "BU8L: Scanner SUCCESS\n"
5555+ with
5656+ | Yamle.Error.Yamle_error e ->
5757+ Printf.printf "BU8L: FAILED with %s\n\n" (Yamle.Error.to_string e)
5858+ | e ->
5959+ Printf.printf "BU8L: FAILED with %s\n\n" (Printexc.to_string e)
6060+6161+let test_ske5 () =
6262+ print_endline "Testing SKE5: Anchor before zero indented sequence";
6363+ let yaml = {|---
6464+seq:
6565+ &anchor
6666+- a
6767+- b|} in
6868+ try
6969+ let scanner = Yamle.Scanner.of_string yaml in
7070+ let rec count_tokens n =
7171+ match Yamle.Scanner.peek scanner with
7272+ | Some { token = Stream_end; _ } ->
7373+ ignore (Yamle.Scanner.next scanner);
7474+ n
7575+ | Some _ ->
7676+ ignore (Yamle.Scanner.next scanner);
7777+ count_tokens (n + 1)
7878+ | None -> n
7979+ in
8080+ let count = count_tokens 0 in
8181+ Printf.printf "SKE5: SUCCESS (tokens: %d)\n\n" count
8282+ with
8383+ | Yamle.Error.Yamle_error e ->
8484+ Printf.printf "SKE5: FAILED with %s\n\n" (Yamle.Error.to_string e)
8585+ | e ->
8686+ Printf.printf "SKE5: FAILED with %s\n\n" (Printexc.to_string e)
8787+8888+let test_rzp5 () =
8989+ print_endline "Testing RZP5: Various Trailing Comments [1.3]";
9090+ let yaml = {|a: "double
9191+ quotes" # lala
9292+b: plain
9393+ value # lala
9494+c : #lala
9595+ d
9696+? # lala
9797+ - seq1
9898+: # lala
9999+ - #lala
100100+ seq2
101101+e: &node # lala
102102+ - x: y
103103+block: > # lala
104104+ abcde|} in
105105+ try
106106+ let scanner = Yamle.Scanner.of_string yaml in
107107+ let rec count_tokens n =
108108+ match Yamle.Scanner.peek scanner with
109109+ | Some { token = Stream_end; _ } ->
110110+ ignore (Yamle.Scanner.next scanner);
111111+ n
112112+ | Some _ ->
113113+ ignore (Yamle.Scanner.next scanner);
114114+ count_tokens (n + 1)
115115+ | None -> n
116116+ in
117117+ let count = count_tokens 0 in
118118+ Printf.printf "RZP5: SUCCESS (tokens: %d)\n\n" count
119119+ with
120120+ | Yamle.Error.Yamle_error e ->
121121+ Printf.printf "RZP5: FAILED with %s\n\n" (Yamle.Error.to_string e)
122122+ | e ->
123123+ Printf.printf "RZP5: FAILED with %s\n\n" (Printexc.to_string e)
124124+125125+let test_xw4d () =
126126+ print_endline "Testing XW4D: Various Trailing Comments";
127127+ let yaml = {|a: "double
128128+ quotes" # lala
129129+b: plain
130130+ value # lala
131131+c : #lala
132132+ d
133133+? # lala
134134+ - seq1
135135+: # lala
136136+ - #lala
137137+ seq2
138138+e:
139139+ &node # lala
140140+ - x: y
141141+block: > # lala
142142+ abcde|} in
143143+ try
144144+ let scanner = Yamle.Scanner.of_string yaml in
145145+ let rec count_tokens n =
146146+ match Yamle.Scanner.peek scanner with
147147+ | Some { token = Stream_end; _ } ->
148148+ ignore (Yamle.Scanner.next scanner);
149149+ n
150150+ | Some _ ->
151151+ ignore (Yamle.Scanner.next scanner);
152152+ count_tokens (n + 1)
153153+ | None -> n
154154+ in
155155+ let count = count_tokens 0 in
156156+ Printf.printf "XW4D: SUCCESS (tokens: %d)\n\n" count
157157+ with
158158+ | Yamle.Error.Yamle_error e ->
159159+ Printf.printf "XW4D: FAILED with %s\n\n" (Yamle.Error.to_string e)
160160+ | e ->
161161+ Printf.printf "XW4D: FAILED with %s\n\n" (Printexc.to_string e)
162162+163163+let () =
164164+ test_bu8l ();
165165+ test_ske5 ();
166166+ test_rzp5 ();
167167+ test_xw4d ()
+11
yaml/ocaml-yamle/tests/test_basic_yaml.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "key: value\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let events = Parser.to_list parser in
99+ Printf.printf "Events: %d\n" (List.length events)
1010+ with e ->
1111+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+18
yaml/ocaml-yamle/tests/test_bs4k.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "word1 # comment\nword2\n" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ Format.printf "Parsing:@.";
77+ try
88+ let parser = Parser.of_string yaml in
99+ let events = Parser.to_list parser in
1010+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1111+ List.iter (fun e ->
1212+ Format.printf " %a@." Event.pp e.Event.event
1313+ ) events
1414+ with
1515+ | Yamle_error e ->
1616+ Format.printf "Error (expected): %a@." Error.pp e
1717+ | e ->
1818+ Format.printf "Error: %s@." (Printexc.to_string e)
+21
yaml/ocaml-yamle/tests/test_debug_stale.ml
···11+open Yamle
22+33+(* Patch Scanner to add debug output *)
44+let test yaml =
55+ Printf.printf "YAML:\n%s\n\n" yaml;
66+ let scanner = Scanner.of_string yaml in
77+ try
88+ let rec loop () =
99+ match Scanner.next scanner with
1010+ | None -> Printf.printf "Done\n"
1111+ | Some tok ->
1212+ Printf.printf "%s\n" (Format.asprintf "%a" Token.pp_spanned tok);
1313+ loop ()
1414+ in
1515+ loop ()
1616+ with e ->
1717+ Printf.printf "Error: %s\n" (Printexc.to_string e)
1818+1919+let () =
2020+ (* This should work: simple key, value on next line *)
2121+ test "d:\n e"
+21
yaml/ocaml-yamle/tests/test_dk4h.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "---\n[ key\n : value ]\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ let scanner = Scanner.of_string yaml in
77+ Printf.printf "\nTokens:\n";
88+ try
99+ let rec loop () =
1010+ match Scanner.next scanner with
1111+ | None -> Printf.printf " (none)\n"
1212+ | Some tok ->
1313+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
1414+ (Format.asprintf "%a" Token.pp tok.token);
1515+ match tok.token with
1616+ | Token.Stream_end -> ()
1717+ | _ -> loop ()
1818+ in
1919+ loop ()
2020+ with e ->
2121+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+9
yaml/ocaml-yamle/tests/test_error_type.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "d:\n e" in
55+ let scanner = Scanner.of_string yaml in
66+ try
77+ while Scanner.next scanner <> None do () done
88+ with Error.Yamle_error err ->
99+ Printf.printf "Error: %s\n" (Error.to_string err)
+6
yaml/ocaml-yamle/tests/test_indent_debug.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "d:\n e" in
55+ let scanner = Scanner.of_string yaml in
66+ ignore (Scanner.to_list scanner)
+18
yaml/ocaml-yamle/tests/test_ks4u.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "---\n[\nsequence item\n]\ninvalid item\n" in
55+ Format.printf "YAML: %S@.@." yaml;
66+ Format.printf "Parsing:@.";
77+ try
88+ let parser = Parser.of_string yaml in
99+ let events = Parser.to_list parser in
1010+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
1111+ List.iter (fun e ->
1212+ Format.printf " %a@." Event.pp e.Event.event
1313+ ) events
1414+ with
1515+ | Yamle_error e ->
1616+ Format.printf "Error (expected): %a@." Error.pp e
1717+ | e ->
1818+ Format.printf "Error: %s@." (Printexc.to_string e)
+21
yaml/ocaml-yamle/tests/test_lhl4.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "---\n!invalid{}tag scalar\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ let scanner = Scanner.of_string yaml in
77+ Printf.printf "\nTokens:\n";
88+ try
99+ let rec loop () =
1010+ match Scanner.next scanner with
1111+ | None -> Printf.printf " (none)\n"
1212+ | Some tok ->
1313+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
1414+ (Format.asprintf "%a" Token.pp tok.token);
1515+ match tok.token with
1616+ | Token.Stream_end -> ()
1717+ | _ -> loop ()
1818+ in
1919+ loop ()
2020+ with e ->
2121+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+9
yaml/ocaml-yamle/tests/test_loader_debug.ml
···11+module TL = Test_suite_lib.Test_suite_loader
22+33+let () =
44+ Printf.printf "Testing test loader...\n";
55+ try
66+ let tests = TL.load_file "../yaml-test-suite/src/229Q.yaml" in
77+ Printf.printf "Loaded %d tests\n" (List.length tests)
88+ with e ->
99+ Printf.printf "Error loading: %s\n" (Printexc.to_string e)
+11
yaml/ocaml-yamle/tests/test_mus6_debug.ml
···11+open Yamle
22+let () =
33+ let yaml = "%YAML 1.1#...\n---\n" in
44+ Format.printf "YAML: %S@.@." yaml;
55+ try
66+ let parser = Parser.of_string yaml in
77+ let events = Parser.to_list parser in
88+ Format.printf "Events: %d (ERROR: should have failed)@." (List.length events)
99+ with
1010+ | Yamle_error e ->
1111+ Format.printf "Error (expected): %a@." Error.pp e
+47
yaml/ocaml-yamle/tests/test_nat4_a.ml
···11+(* Test NAT4 case a specifically *)
22+open Yamle
33+44+let test_case desc yaml expected =
55+ Printf.printf "\n=== %s ===\n" desc;
66+ Printf.printf "Input: %s\n" (String.escaped yaml);
77+ try
88+ let parser = Parser.of_string yaml in
99+ let events = Parser.to_list parser in
1010+ List.iter (fun (e : Event.spanned) ->
1111+ match e.event with
1212+ | Event.Scalar { value; style; _ } ->
1313+ Printf.printf "Output: %s (len=%d, style=%s)\n"
1414+ (String.escaped value)
1515+ (String.length value)
1616+ (match style with
1717+ | Scalar_style.Single_quoted -> "single"
1818+ | Scalar_style.Double_quoted -> "double"
1919+ | _ -> "other");
2020+ Printf.printf "Expected: %s (len=%d)\n" (String.escaped expected) (String.length expected);
2121+ if value = expected then
2222+ Printf.printf "✓ PASS\n"
2323+ else
2424+ Printf.printf "✗ FAIL\n"
2525+ | _ -> ()
2626+ ) events
2727+ with e ->
2828+ Printf.printf "Error: %s\n" (Printexc.to_string e)
2929+3030+let () =
3131+ (* NAT4 case a: newline then spaces *)
3232+ test_case "a" "a: '\n '" " ";
3333+3434+ (* NAT4 case b: spaces, newline, spaces *)
3535+ test_case "b" "a: ' \n '" " ";
3636+3737+ (* NAT4 case e: newline, empty line, spaces *)
3838+ test_case "e" "a: '\n\n '" "\n";
3939+4040+ (* NAT4 case g: newline, two empty lines, spaces *)
4141+ test_case "g" "a: '\n\n\n '" "\n\n";
4242+4343+ (* Simple case: text on both lines *)
4444+ test_case "simple" "a: 'foo\nbar'" "foo bar";
4545+4646+ (* Case with empty line between text *)
4747+ test_case "empty_between" "a: 'foo\n\nbar'" "foo\nbar";
+31
yaml/ocaml-yamle/tests/test_remaining.ml
···11+open Yamle
22+33+let test yaml name =
44+ Printf.printf "\n=== %s ===\n" name;
55+ Printf.printf "YAML: %S\n" yaml;
66+ try
77+ let parser = Parser.of_string yaml in
88+ let _ = Parser.to_list parser in
99+ Printf.printf "SUCCESS\n"
1010+ with Error.Yamle_error _ ->
1111+ Printf.printf "ERROR\n"
1212+1313+let () =
1414+ (* CT4Q: Single Pair Explicit Entry *)
1515+ test {|[
1616+? foo
1717+ bar : baz
1818+]|} "CT4Q";
1919+2020+ (* DFF7: Flow Mapping Entries *)
2121+ test {|{
2222+? explicit: entry,
2323+implicit: entry,
2424+?
2525+}|} "DFF7";
2626+2727+ (* FRK4: Completely Empty Flow Nodes *)
2828+ test {|{
2929+ ? foo :,
3030+ : bar,
3131+}|} "FRK4";
+30
yaml/ocaml-yamle/tests/test_simple_key_debug.ml
···11+open Yamle
22+33+let test_case name yaml =
44+ Printf.printf "\n=== Testing %s ===\n" name;
55+ Printf.printf "YAML:\n%s\n\n" yaml;
66+ let scanner = Scanner.of_string yaml in
77+ Printf.printf "Tokens:\n";
88+ let rec print_tokens () =
99+ match Scanner.next scanner with
1010+ | None -> Printf.printf "Done\n"
1111+ | Some tok ->
1212+ Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok);
1313+ print_tokens ()
1414+ in
1515+ try
1616+ print_tokens ()
1717+ with e ->
1818+ Printf.printf "Error: %s\n" (Printexc.to_string e)
1919+2020+let () =
2121+ (* Test A984 - Multiline Scalar in Mapping *)
2222+ test_case "A984" "a: b\n c\nd:\n e\n f";
2323+2424+ (* Test RZP5 - Trailing Comments *)
2525+ test_case "RZP5" "- #lala\n seq2";
2626+2727+ (* Simplified versions *)
2828+ test_case "Simple multiline" "a: b\n c";
2929+ test_case "Simple block entry with comment" "- # comment\n value";
3030+ test_case "After block scalar" "a: |\n text\nb: c"
+21
yaml/ocaml-yamle/tests/test_simple_single.ml
···11+(* Simple test of single-quoted scalar *)
22+open Yamle
33+44+let () =
55+ let yaml = "'foo\n\nbar'" in
66+ Printf.printf "Input: %s\n" (String.escaped yaml);
77+88+ let scanner = Scanner.of_string yaml in
99+ Scanner.iter (fun tok ->
1010+ match tok.Token.token with
1111+ | Token.Scalar { value; style; _ } ->
1212+ Printf.printf "Scalar: %s (len=%d)\n" (String.escaped value) (String.length value);
1313+ Printf.printf "Style: %s\n" (match style with
1414+ | Scalar_style.Single_quoted -> "single"
1515+ | _ -> "other");
1616+ (* Print each character *)
1717+ for i = 0 to String.length value - 1 do
1818+ Printf.printf " [%d] = %C (code=%d)\n" i value.[i] (Char.code value.[i])
1919+ done
2020+ | _ -> ()
2121+ ) scanner
···11+(* Load yaml-test-suite test cases from YAML format *)
22+open Yamle
33+44+type test_case = {
55+ id : string;
66+ name : string;
77+ yaml : string;
88+ tree : string option;
99+ fail : bool;
1010+}
1111+1212+let read_file path =
1313+ let ic = open_in path in
1414+ let n = in_channel_length ic in
1515+ let s = really_input_string ic n in
1616+ close_in ic;
1717+ s
1818+1919+(* Convert YAML test suite visual representations to actual characters *)
2020+let convert_test_yaml yaml =
2121+ let result = Buffer.create (String.length yaml) in
2222+ let len = String.length yaml in
2323+ let rec process i =
2424+ if i >= len then ()
2525+ else
2626+ (* Check for multi-character sequences - must check longest first *)
2727+ (* ————» = em-dash em-dash em-dash em-dash guillemet (4 spaces = tab expanded) *)
2828+ if i + 14 <= len && String.sub yaml i 14 = "\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xc2\xbb" then begin
2929+ Buffer.add_char result '\t';
3030+ process (i + 14)
3131+ end
3232+ (* ———» = em-dash em-dash em-dash guillemet *)
3333+ else if i + 11 <= len && String.sub yaml i 11 = "\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xc2\xbb" then begin
3434+ Buffer.add_char result '\t';
3535+ process (i + 11)
3636+ end
3737+ (* ——» = em-dash em-dash guillemet *)
3838+ else if i + 8 <= len && String.sub yaml i 8 = "\xe2\x80\x94\xe2\x80\x94\xc2\xbb" then begin
3939+ Buffer.add_char result '\t';
4040+ process (i + 8)
4141+ end
4242+ (* —» = em-dash guillemet *)
4343+ else if i + 5 <= len && String.sub yaml i 5 = "\xe2\x80\x94\xc2\xbb" then begin
4444+ Buffer.add_char result '\t';
4545+ process (i + 5)
4646+ end
4747+ (* » = guillemet alone *)
4848+ else if i + 2 <= len && String.sub yaml i 2 = "\xc2\xbb" then begin
4949+ Buffer.add_char result '\t';
5050+ process (i + 2)
5151+ end
5252+ (* ␣ = open box for trailing space *)
5353+ else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x90\xa3" then begin
5454+ Buffer.add_char result ' ';
5555+ process (i + 3)
5656+ end
5757+ (* ← = leftwards arrow for carriage return *)
5858+ else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x86\x90" then begin
5959+ Buffer.add_char result '\r';
6060+ process (i + 3)
6161+ end
6262+ (* ⇔ = left-right double arrow for BOM *)
6363+ else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x87\x94" then begin
6464+ Buffer.add_string result "\xEF\xBB\xBF";
6565+ process (i + 3)
6666+ end
6767+ (* ↵ = up-down arrow for explicit newline.
6868+ This represents a newline in the output AND replaces the following actual newline
6969+ (since each ↵ is on its own line in the test file's yaml field). *)
7070+ else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x86\xb5" then begin
7171+ Buffer.add_char result '\n';
7272+ (* Skip the following newline if present (it's part of the test file structure, not content) *)
7373+ let next_i = i + 3 in
7474+ if next_i < len && yaml.[next_i] = '\n' then
7575+ process (next_i + 1)
7676+ else
7777+ process next_i
7878+ end
7979+ (* ∎ = end-of-proof symbol for empty stream *)
8080+ else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x88\x8e" then begin
8181+ (* Skip this - it represents an empty file, so we add nothing *)
8282+ process (i + 3)
8383+ end
8484+ else begin
8585+ Buffer.add_char result yaml.[i];
8686+ process (i + 1)
8787+ end
8888+ in
8989+ process 0;
9090+ Buffer.contents result
9191+9292+(* Extract a field value from parsed YAML events *)
9393+let extract_mapping_value events key =
9494+ let rec find_key = function
9595+ | [] -> None
9696+ | { Event.event = Event.Scalar { value; _ }; _ } :: rest when value = key ->
9797+ (* Found the key, now get the value *)
9898+ (match rest with
9999+ | { Event.event = Event.Scalar { value; _ }; _ } :: _ -> Some value
100100+ | _ -> None)
101101+ | _ :: rest -> find_key rest
102102+ in
103103+ find_key events
104104+105105+(* Parse a single test case from a mapping *)
106106+let parse_test_case id events =
107107+ let name = match extract_mapping_value events "name" with
108108+ | Some n -> n
109109+ | None -> id
110110+ in
111111+ let yaml = match extract_mapping_value events "yaml" with
112112+ | Some y -> convert_test_yaml y
113113+ | None -> ""
114114+ in
115115+ let tree = extract_mapping_value events "tree" in
116116+ let fail = match extract_mapping_value events "fail" with
117117+ | Some "true" -> true
118118+ | _ -> Option.is_some (extract_mapping_value events "error")
119119+ in
120120+ { id; name; yaml; tree; fail }
121121+122122+(* Load tests from a single YAML file *)
123123+let load_file path =
124124+ let id = Filename.chop_extension (Filename.basename path) in
125125+ try
126126+ let content = read_file path in
127127+ let parser = Parser.of_string content in
128128+ let events = Parser.to_list parser in
129129+130130+ (* File contains a sequence of test cases *)
131131+ let tests = ref [] in
132132+ let current_events = ref [] in
133133+ let in_mapping = ref false in
134134+ let depth = ref 0 in
135135+ let test_index = ref 0 in
136136+137137+ List.iter (fun (e : Event.spanned) ->
138138+ match e.event with
139139+ | Event.Mapping_start _ when !depth = 1 ->
140140+ in_mapping := true;
141141+ current_events := [e];
142142+ incr depth
143143+ | Event.Mapping_end when !depth = 2 ->
144144+ current_events := e :: !current_events;
145145+ let test_id = if !test_index = 0 then id else Printf.sprintf "%s/%02d" id !test_index in
146146+ let test = parse_test_case test_id (List.rev !current_events) in
147147+ if test.yaml <> "" then tests := test :: !tests;
148148+ in_mapping := false;
149149+ current_events := [];
150150+ incr test_index;
151151+ decr depth
152152+ | _ when !in_mapping ->
153153+ current_events := e :: !current_events;
154154+ (match e.event with
155155+ | Event.Mapping_start _ | Event.Sequence_start _ -> incr depth
156156+ | Event.Mapping_end | Event.Sequence_end -> decr depth
157157+ | _ -> ())
158158+ | Event.Sequence_start _ when !depth = 0 -> depth := 1
159159+ | Event.Sequence_end when !depth = 1 -> depth := 0
160160+ | _ -> ()
161161+ ) events;
162162+163163+ List.rev !tests
164164+ with _ -> []
165165+166166+let load_directory src_path =
167167+ let entries = Sys.readdir src_path in
168168+ let tests = ref [] in
169169+ Array.iter (fun entry ->
170170+ if Filename.check_suffix entry ".yaml" then begin
171171+ let path = Filename.concat src_path entry in
172172+ let file_tests = load_file path in
173173+ tests := file_tests @ !tests
174174+ end
175175+ ) entries;
176176+ List.sort (fun a b -> String.compare a.id b.id) !tests
···11+(* Format parser events as tree notation compatible with yaml-test-suite *)
22+33+open Yamle
44+55+let escape_string s =
66+ let buf = Buffer.create (String.length s * 2) in
77+ let len = String.length s in
88+ (* Find the last non-space character to identify trailing spaces *)
99+ let rec find_last_non_space i =
1010+ if i < 0 then -1
1111+ else if s.[i] <> ' ' then i
1212+ else find_last_non_space (i - 1)
1313+ in
1414+ let last_non_space = find_last_non_space (len - 1) in
1515+1616+ String.iteri (fun i c ->
1717+ match c with
1818+ | '\n' -> Buffer.add_string buf "\\n"
1919+ | '\t' -> Buffer.add_string buf "\\t"
2020+ | '\r' -> Buffer.add_string buf "\\r"
2121+ | '\\' -> Buffer.add_string buf "\\\\"
2222+ | '\x00' -> Buffer.add_string buf "\\0"
2323+ | '\x07' -> Buffer.add_string buf "\\a"
2424+ | '\x08' -> Buffer.add_string buf "\\b"
2525+ | '\x0b' -> Buffer.add_string buf "\\v"
2626+ | '\x0c' -> Buffer.add_string buf "\\f"
2727+ | '\x1b' -> Buffer.add_string buf "\\e"
2828+ | '\xa0' -> Buffer.add_string buf "\\_"
2929+ | ' ' when i > last_non_space ->
3030+ (* Trailing space - show with open box character *)
3131+ Buffer.add_string buf "\xe2\x90\xa3"
3232+ | c -> Buffer.add_char buf c
3333+ ) s;
3434+ Buffer.contents buf
3535+3636+let style_char = function
3737+ | Scalar_style.Plain -> ':'
3838+ | Scalar_style.Single_quoted -> '\''
3939+ | Scalar_style.Double_quoted -> '"'
4040+ | Scalar_style.Literal -> '|'
4141+ | Scalar_style.Folded -> '>'
4242+ | Scalar_style.Any -> ':'
4343+4444+let format_event depth { Event.event; span = _span } =
4545+ let indent = String.make depth ' ' in
4646+ match event with
4747+ | Event.Stream_start _ -> "+STR"
4848+ | Event.Stream_end -> "-STR"
4949+ | Event.Document_start { implicit; _ } ->
5050+ if implicit then Printf.sprintf "%s+DOC" indent
5151+ else Printf.sprintf "%s+DOC ---" indent
5252+ | Event.Document_end { implicit } ->
5353+ if implicit then Printf.sprintf "%s-DOC" indent
5454+ else Printf.sprintf "%s-DOC ..." indent
5555+ | Event.Mapping_start { anchor; tag; style; _ } ->
5656+ let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
5757+ let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
5858+ let flow_str = match style with Layout_style.Flow -> " {}" | _ -> "" in
5959+ Printf.sprintf "%s+MAP%s%s%s" indent flow_str anchor_str tag_str
6060+ | Event.Mapping_end -> Printf.sprintf "%s-MAP" indent
6161+ | Event.Sequence_start { anchor; tag; style; _ } ->
6262+ let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
6363+ let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
6464+ let flow_str = match style with Layout_style.Flow -> " []" | _ -> "" in
6565+ Printf.sprintf "%s+SEQ%s%s%s" indent flow_str anchor_str tag_str
6666+ | Event.Sequence_end -> Printf.sprintf "%s-SEQ" indent
6767+ | Event.Scalar { anchor; tag; value; style; _ } ->
6868+ let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
6969+ let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
7070+ let style_c = style_char style in
7171+ Printf.sprintf "%s=VAL%s%s %c%s" indent anchor_str tag_str style_c (escape_string value)
7272+ | Event.Alias { anchor } ->
7373+ Printf.sprintf "%s=ALI *%s" indent anchor
7474+7575+let of_spanned_events events =
7676+ let buf = Buffer.create 256 in
7777+ let depth = ref 0 in
7878+ List.iter (fun (e : Event.spanned) ->
7979+ (match e.event with
8080+ | Event.Stream_end | Event.Document_end _ | Event.Mapping_end | Event.Sequence_end ->
8181+ decr depth
8282+ | _ -> ());
8383+ let line = format_event !depth e in
8484+ Buffer.add_string buf line;
8585+ Buffer.add_char buf '\n';
8686+ (match e.event with
8787+ | Event.Stream_start _ | Event.Document_start _ | Event.Mapping_start _ | Event.Sequence_start _ ->
8888+ incr depth
8989+ | _ -> ())
9090+ ) events;
9191+ Buffer.contents buf
+21
yaml/ocaml-yamle/tests/test_sy6v.ml
···11+open Yamle
22+33+let () =
44+ let yaml = "&anchor - sequence entry\n" in
55+ Printf.printf "YAML: %S\n" yaml;
66+ let scanner = Scanner.of_string yaml in
77+ Printf.printf "\nTokens:\n";
88+ try
99+ let rec loop () =
1010+ match Scanner.next scanner with
1111+ | None -> Printf.printf " (none)\n"
1212+ | Some tok ->
1313+ Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
1414+ (Format.asprintf "%a" Token.pp tok.token);
1515+ match tok.token with
1616+ | Token.Stream_end -> ()
1717+ | _ -> loop ()
1818+ in
1919+ loop ()
2020+ with e ->
2121+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+24
yaml/ocaml-yamle/tests/test_tokens2.ml
···11+open Yamle
22+33+let yaml = {|'implicit block key' : [
44+ 'implicit flow key' : value,
55+ ]|}
66+77+let () =
88+ let scanner = Scanner.of_string yaml in
99+ let rec print_all n =
1010+ match Scanner.next scanner with
1111+ | None -> ()
1212+ | Some tok ->
1313+ Printf.printf "%2d. " n;
1414+ (match tok.Token.token with
1515+ | Token.Flow_sequence_start -> Printf.printf "Flow_sequence_start"
1616+ | Token.Flow_sequence_end -> Printf.printf "Flow_sequence_end"
1717+ | Token.Flow_entry -> Printf.printf "Flow_entry"
1818+ | Token.Value -> Printf.printf "Value"
1919+ | Token.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
2020+ | _ -> Printf.printf "Other");
2121+ Printf.printf " at %d:%d\n" tok.span.start.line tok.span.start.column;
2222+ print_all (n + 1)
2323+ in
2424+ print_all 0
+19
yaml/ocaml-yamle/tests/test_trace_a984.ml
···11+open Yamle
22+33+let () =
44+ (* Minimal A984 reproduction *)
55+ let yaml = "d:\n e" in
66+ Printf.printf "Testing minimal A984:\n%s\n\n" yaml;
77+ let scanner = Scanner.of_string yaml in
88+ Printf.printf "Tokens:\n";
99+ let rec print_tokens () =
1010+ match Scanner.next scanner with
1111+ | None -> Printf.printf "Done\n"
1212+ | Some tok ->
1313+ Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok);
1414+ print_tokens ()
1515+ in
1616+ try
1717+ print_tokens ()
1818+ with e ->
1919+ Printf.printf "Error: %s\n" (Printexc.to_string e)
+41
yaml/ocaml-yamle/tests/test_y79y.ml
···11+(* Debug Y79Y test cases *)
22+open Yamle
33+44+let () =
55+ (* Test case 1: fail=true - tabs at wrong indentation in block scalar *)
66+ let yaml1 = "foo: |\n \t\nbar: 1" in
77+ Printf.printf "=== Test 1 (should fail) ===\n";
88+ Printf.printf "Input: %S\n" yaml1;
99+ Printf.printf "Visual:\n";
1010+ String.iter (fun c ->
1111+ if c = '\t' then Printf.printf "<TAB>"
1212+ else if c = '\n' then Printf.printf "<NL>\n"
1313+ else Printf.printf "%c" c
1414+ ) yaml1;
1515+ Printf.printf "\n";
1616+ (try
1717+ let parser = Parser.of_string yaml1 in
1818+ let events = Parser.to_list parser in
1919+ Printf.printf "Events: %d\n" (List.length events);
2020+ Printf.printf "ERROR: Should have failed but didn't!\n\n"
2121+ with e ->
2222+ Printf.printf "Failed as expected: %s\n\n" (Printexc.to_string e));
2323+2424+ (* Test case 2: should succeed - tab with proper indentation in block scalar *)
2525+ let yaml2 = "foo: |\n \t\nbar: 1" in
2626+ Printf.printf "=== Test 2 (should succeed) ===\n";
2727+ Printf.printf "Input: %S\n" yaml2;
2828+ Printf.printf "Visual:\n";
2929+ String.iter (fun c ->
3030+ if c = '\t' then Printf.printf "<TAB>"
3131+ else if c = '\n' then Printf.printf "<NL>\n"
3232+ else Printf.printf "%c" c
3333+ ) yaml2;
3434+ Printf.printf "\n";
3535+ (try
3636+ let parser = Parser.of_string yaml2 in
3737+ let events = Parser.to_list parser in
3838+ Printf.printf "Events: %d\n" (List.length events);
3939+ Printf.printf "\n"
4040+ with e ->
4141+ Printf.printf "ERROR: Failed but should succeed: %s\n\n" (Printexc.to_string e))
+68
yaml/ocaml-yamle/tests/test_y79y_all.ml
···11+(* Test all Y79Y cases *)
22+33+let test_case name yaml should_fail =
44+ Printf.printf "=== %s ===\n" name;
55+ try
66+ let scanner = Yamle.Scanner.of_string yaml in
77+ let _tokens = Yamle.Scanner.to_list scanner in
88+ if should_fail then begin
99+ Printf.printf "FAIL: Expected error but parsing succeeded\n";
1010+ false
1111+ end else begin
1212+ Printf.printf "PASS: Parsing succeeded as expected\n";
1313+ true
1414+ end
1515+ with e ->
1616+ if should_fail then begin
1717+ Printf.printf "PASS: Failed as expected (%s)\n" (Printexc.to_string e);
1818+ true
1919+ end else begin
2020+ Printf.printf "FAIL: Unexpected error (%s)\n" (Printexc.to_string e);
2121+ false
2222+ end
2323+2424+let () =
2525+ let results = ref [] in
2626+2727+ (* Y79Y/00: Tab at start - should FAIL *)
2828+ results := test_case "Y79Y/00" "foo: |\n\t\nbar: 1" true :: !results;
2929+3030+ (* Y79Y/01: Tab after 1 space - should PASS *)
3131+ results := test_case "Y79Y/01" "foo: |\n \t\nbar: 1" false :: !results;
3232+3333+ (* Y79Y/02: Tab in flow sequence after newline - should PASS *)
3434+ results := test_case "Y79Y/02" "- [\n\t\n foo\n ]" false :: !results;
3535+3636+ (* Y79Y/03: Tab immediately after flow start and content - should FAIL *)
3737+ results := test_case "Y79Y/03" "- [\n\tfoo,\n foo\n ]" true :: !results;
3838+3939+ (* Y79Y/04: Tab after dash at root level - should FAIL *)
4040+ results := test_case "Y79Y/04" "-\t-" true :: !results;
4141+4242+ (* Y79Y/05: Tab after dash with space - should FAIL *)
4343+ results := test_case "Y79Y/05" "- \t-" true :: !results;
4444+4545+ (* Y79Y/06: Tab after ? at root level - should FAIL *)
4646+ results := test_case "Y79Y/06" "?\t-" true :: !results;
4747+4848+ (* Y79Y/07: Tab after : in explicit mapping - should FAIL *)
4949+ results := test_case "Y79Y/07" "? -\n:\t-" true :: !results;
5050+5151+ (* Y79Y/08: Tab after ? before key - should FAIL *)
5252+ results := test_case "Y79Y/08" "?\tkey:" true :: !results;
5353+5454+ (* Y79Y/09: Tab after : in explicit mapping - should FAIL *)
5555+ results := test_case "Y79Y/09" "? key:\n:\tkey:" true :: !results;
5656+5757+ (* Y79Y/10: Tab before number (content) - should PASS *)
5858+ results := test_case "Y79Y/10" "-\t-1" false :: !results;
5959+6060+ Printf.printf "\n=== Summary ===\n";
6161+ let passed = List.filter (fun x -> x) !results |> List.length in
6262+ let total = List.length !results in
6363+ Printf.printf "%d/%d tests passed\n" passed total;
6464+ if passed = total then
6565+ Printf.printf "All tests PASSED!\n"
6666+ else
6767+ Printf.printf "Some tests FAILED\n";
6868+ exit (if passed = total then 0 else 1)
+13
yaml/ocaml-yamle/tests/test_y79y_simple.ml
···11+(* Simple Y79Y test *)
22+33+let () =
44+ (* Test case 1: should fail - tab at wrong indentation *)
55+ let yaml1 = "foo: |\n \t\nbar: 1" in
66+ Printf.printf "=== Test 1 (should fail) ===\n";
77+ Printf.printf "Testing: %S\n" yaml1;
88+ (try
99+ let scanner = Yamle.Scanner.of_string yaml1 in
1010+ let _tokens = Yamle.Scanner.to_list scanner in
1111+ Printf.printf "ERROR: Scanning succeeded but should have failed!\n"
1212+ with e ->
1313+ Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e))
+44
yaml/ocaml-yamle/tests/test_y79y_trace.ml
···11+(* Trace Y79Y test *)
22+33+let test_case yaml desc should_fail expected_scalars =
44+ Printf.printf "=== %s ===\n" desc;
55+ Printf.printf "Testing: %S\n" yaml;
66+ try
77+ let scanner = Yamle.Scanner.of_string yaml in
88+ let tokens = Yamle.Scanner.to_list scanner in
99+ if should_fail then
1010+ Printf.printf "ERROR: Expected to fail but got %d tokens\n" (List.length tokens)
1111+ else begin
1212+ Printf.printf "OK: Got %d tokens\n" (List.length tokens);
1313+ let scalars = ref [] in
1414+ List.iter (fun (t : Yamle.Token.spanned) ->
1515+ match t.token with
1616+ | Yamle.Token.Scalar { value; _ } ->
1717+ scalars := value :: !scalars;
1818+ Printf.printf " Scalar: %S\n" value
1919+ | _ -> ()
2020+ ) tokens;
2121+ let scalars = List.rev !scalars in
2222+ if scalars <> expected_scalars then begin
2323+ Printf.printf "ERROR: Expected scalars %s but got %s\n"
2424+ (String.concat ", " (List.map (Printf.sprintf "%S") expected_scalars))
2525+ (String.concat ", " (List.map (Printf.sprintf "%S") scalars))
2626+ end
2727+ end
2828+ with e ->
2929+ if should_fail then
3030+ Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e)
3131+ else
3232+ Printf.printf "ERROR: Unexpected failure: %s\n" (Printexc.to_string e)
3333+3434+let () =
3535+ (* Test case 0 (Y79Y): should fail - tab at start of content *)
3636+ let yaml0 = "foo: |\n\t\nbar: 1" in
3737+ test_case yaml0 "Y79Y/00: tab at start (no spaces)" true [];
3838+ Printf.printf "\n";
3939+4040+ (* Test case 1 (Y79Y/01): should succeed - tab after 1 space indent *)
4141+ (* Expected: foo="\t\n", bar="1" *)
4242+ let yaml1 = "foo: |\n \t\nbar: 1" in
4343+ test_case yaml1 "Y79Y/01: tab after 1 space" false ["foo"; "\t\n"; "bar"; "1"];
4444+ Printf.printf "\n"