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

loads

+93
yaml/ocaml-yamle/tests/categorize_failures.ml
···
+
(* Categorize test failures *)
+
open Yamle
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
+
let test_suite_path = "../yaml-test-suite"
+
+
let normalize_tree s =
+
let lines = String.split_on_char '\n' s in
+
let lines = List.filter (fun l -> String.trim l <> "") lines in
+
String.concat "\n" lines
+
+
type failure =
+
| Error_not_detected of string
+
| Parse_error of string
+
| Tree_mismatch of string * string
+
+
let run_test (test : TL.test_case) =
+
if test.fail then begin
+
try
+
let parser = Parser.of_string test.yaml in
+
let _events = Parser.to_list parser in
+
Some (Error_not_detected test.name)
+
with _ -> None
+
end
+
else begin
+
match test.tree with
+
| None -> None
+
| Some expected ->
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
let actual = TF.of_spanned_events events in
+
let expected_norm = normalize_tree expected in
+
let actual_norm = normalize_tree actual in
+
if expected_norm = actual_norm then None
+
else Some (Tree_mismatch (expected_norm, actual_norm))
+
with e ->
+
let msg = Printexc.to_string e in
+
Some (Parse_error msg)
+
end
+
+
let diff_lines expected actual =
+
let exp_lines = String.split_on_char '\n' expected in
+
let act_lines = String.split_on_char '\n' actual in
+
let rec find_diff i es as_ =
+
match es, as_ with
+
| [], [] -> None
+
| [], _ -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines))
+
| _, [] -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines))
+
| e :: es', a :: as_' ->
+
if e = a then find_diff (i + 1) es' as_'
+
else Some (Printf.sprintf "Line %d differs:\n exp: %s\n got: %s" i e a)
+
in
+
find_diff 1 exp_lines act_lines
+
+
let () =
+
let src_path = Filename.concat test_suite_path "src" in
+
let all_tests = TL.load_directory src_path in
+
+
let error_not_detected = ref [] in
+
let parse_errors = ref [] in
+
let tree_mismatches = ref [] in
+
+
List.iter (fun test ->
+
match run_test test with
+
| None -> ()
+
| Some (Error_not_detected name) ->
+
error_not_detected := (test.TL.id, name) :: !error_not_detected
+
| Some (Parse_error msg) ->
+
parse_errors := (test.TL.id, test.TL.name, msg) :: !parse_errors
+
| Some (Tree_mismatch (exp, act)) ->
+
tree_mismatches := (test.TL.id, test.TL.name, exp, act) :: !tree_mismatches
+
) all_tests;
+
+
Printf.printf "=== ERROR TESTS NOT DETECTED (%d) ===\n" (List.length !error_not_detected);
+
List.iter (fun (id, name) ->
+
Printf.printf " %s: %s\n" id name
+
) (List.rev !error_not_detected);
+
+
Printf.printf "\n=== PARSE ERRORS (%d) ===\n" (List.length !parse_errors);
+
List.iter (fun (id, name, msg) ->
+
Printf.printf " %s: %s\n %s\n" id name msg
+
) (List.rev !parse_errors);
+
+
Printf.printf "\n=== TREE MISMATCHES (%d) ===\n" (List.length !tree_mismatches);
+
List.iter (fun (id, name, exp, act) ->
+
let diff = diff_lines exp act in
+
Printf.printf " %s: %s\n" id name;
+
match diff with
+
| Some d -> Printf.printf " %s\n" d
+
| None -> ()
+
) (List.rev !tree_mismatches)
+12
yaml/ocaml-yamle/tests/count_tests.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
+
let () =
+
let tests = TL.load_directory "../yaml-test-suite/src" in
+
let error_without_tree = List.filter (fun t -> t.TL.fail && t.TL.tree = None) tests in
+
let non_error_without_tree = List.filter (fun t -> (not t.TL.fail) && t.TL.tree = None) tests in
+
Printf.printf "Error tests without tree: %d\n" (List.length error_without_tree);
+
Printf.printf "Non-error tests without tree (will be skipped): %d\n" (List.length non_error_without_tree);
+
Printf.printf "\nError tests without tree:\n";
+
List.iter (fun t -> Printf.printf " %s\n" t.TL.id) error_without_tree;
+
Printf.printf "\nNon-error tests without tree:\n";
+
List.iter (fun t -> Printf.printf " %s\n" t.TL.id) non_error_without_tree
+71
yaml/ocaml-yamle/tests/debug_5we3_6m2f.ml
···
+
open Yamle
+
+
let show_token tok =
+
Format.asprintf "%a" Token.pp_spanned tok
+
+
let show_event evt =
+
Format.asprintf "%a" Event.pp_spanned evt
+
+
let test_5we3 () =
+
Printf.printf "\n=== Test 5WE3: Explicit Block Mapping Entries ===\n";
+
let yaml = "? explicit key # Empty value\n? |\n block key\n: - one # Explicit compact\n - two # block value" in
+
Printf.printf "Input:\n%s\n\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.peek scanner with
+
| None -> Printf.printf "No more tokens\n"
+
| Some tok ->
+
Printf.printf " %s\n" (show_token tok);
+
ignore (Scanner.next scanner);
+
print_tokens ()
+
in
+
print_tokens ();
+
Printf.printf "\nParsing:\n";
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> Printf.printf "No more events\n"
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let test_6m2f () =
+
Printf.printf "\n=== Test 6M2F: Aliases in Explicit Block Mapping ===\n";
+
let yaml = "? &a a\n: &b b\n: *a" in
+
Printf.printf "Input:\n%s\n\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.peek scanner with
+
| None -> Printf.printf "No more tokens\n"
+
| Some tok ->
+
Printf.printf " %s\n" (show_token tok);
+
ignore (Scanner.next scanner);
+
print_tokens ()
+
in
+
print_tokens ();
+
Printf.printf "\nParsing:\n";
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> Printf.printf "No more events\n"
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let () =
+
test_5we3 ();
+
test_6m2f ()
+62
yaml/ocaml-yamle/tests/debug_block_issues.ml
···
+
open Yamle
+
open Test_suite_lib
+
+
let test_case name yaml expected_tree =
+
Printf.printf "\n=== Testing %s ===\n" name;
+
Printf.printf "YAML:\n%s\n" yaml;
+
Printf.printf "\nExpected tree:\n%s\n" expected_tree;
+
+
try
+
let input = Input.of_string yaml in
+
let scanner = Scanner.create input in
+
let parser = Parser.create scanner in
+
+
(* Skip token output for now *)
+
();
+
+
Printf.printf "\nParsing...\n";
+
let rec collect_events acc =
+
match Parser.next parser with
+
| None -> List.rev acc
+
| Some evt -> collect_events (evt :: acc)
+
in
+
let events = collect_events [] in
+
+
let tree = Tree_format.of_spanned_events events in
+
Printf.printf "\nFormatted tree:\n%s\n" tree;
+
+
if tree = expected_tree then
+
Printf.printf "✓ PASS\n"
+
else
+
Printf.printf "✗ FAIL - Tree mismatch\n"
+
with
+
| Error.Yamle_error err ->
+
Printf.printf "ERROR: %s\n" (Error.to_string err)
+
| e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* JEF9 - Extra newlines at end *)
+
test_case "JEF9"
+
"- |+\n\n"
+
"+STR\n +DOC\n +SEQ\n =VAL |\\n\\n\n -SEQ\n -DOC\n-STR";
+
+
(* K858 - Empty scalar chomping - block scalar consuming too much *)
+
test_case "K858"
+
"strip: >-\n\nclip: >\n\nkeep: |+\n\n"
+
"+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";
+
+
(* L24T - Trailing whitespace-only line *)
+
test_case "L24T"
+
"foo: |\n x\n \n"
+
"+STR\n +DOC\n +MAP\n =VAL :foo\n =VAL |x\\n \\n\n -MAP\n -DOC\n-STR";
+
+
(* MJS9 - Folded block newline handling *)
+
test_case "MJS9"
+
">\n foo \n \n \t bar\n\n baz\n"
+
"+STR\n +DOC\n =VAL >foo \\n\\n\\t bar\\n\\nbaz\\n\n -DOC\n-STR";
+
+
(* R4YG - Tab handling in folded block - just the problematic 4th test *)
+
test_case "R4YG-4"
+
"- >\n \t\n detected\n"
+
"+STR\n +DOC\n +SEQ\n =VAL >\\t\\ndetected\\n\n -SEQ\n -DOC\n-STR"
+47
yaml/ocaml-yamle/tests/debug_block_scalars.ml
···
+
(* Debug block scalar behavior *)
+
open Yamle
+
+
let test_simple name yaml expected =
+
Printf.printf "\n=== %s ===\n" name;
+
Printf.printf "Input: %S\n" yaml;
+
Printf.printf "Expected: %S\n" expected;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
List.iter (fun ev ->
+
match ev.Event.event with
+
| Event.Scalar { value; style; _ } ->
+
let style_str = match style with
+
| Scalar_style.Literal -> "Literal"
+
| Scalar_style.Folded -> "Folded"
+
| _ -> "Other"
+
in
+
Printf.printf "Scalar (%s): %S (len=%d)\n" style_str value (String.length value);
+
Printf.printf " Escaped: %s\n" (String.escaped value);
+
if value = expected then
+
Printf.printf " PASS\n"
+
else
+
Printf.printf " FAIL: Expected %S\n" expected
+
| _ -> ()
+
) events
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e);
+
Printexc.print_backtrace stdout
+
+
let () =
+
(* JEF9 - Keep chomping with empty content *)
+
test_simple "JEF9" "- |+\n\n\n" "\n\n";
+
+
(* K858 - Empty scalar chomping *)
+
test_simple "K858-strip" "strip: >-\n\n" "";
+
test_simple "K858-clip" "clip: >\n\n" "";
+
test_simple "K858-keep" "keep: |+\n\n" "\n";
+
+
(* L24T - Trailing spaces *)
+
test_simple "L24T" "foo: |\n x\n \n" "x\n \n";
+
+
(* MJS9 - Folded newlines *)
+
test_simple "MJS9" ">\n foo \n \n\t bar\n\n baz\n" "foo \n\n\t bar\n\nbaz\n";
+
+
(* R4YG - Tab preservation *)
+
test_simple "R4YG" "- >\n \t\n detected\n" "\t\ndetected\n"
+13
yaml/ocaml-yamle/tests/debug_dk95_01.ml
···
+
open Yamle
+
let () =
+
(* DK95/01: foo: "bar<nl><4 tabs>baz" - 4 tabs at column 1 puts us at column 5, but quote started at 6 *)
+
let yaml = "foo: \"bar\n\t\t\t\tbaz\"" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+71
yaml/ocaml-yamle/tests/debug_empty_key.ml
···
+
open Yamle
+
+
let show_token tok =
+
Format.asprintf "%a" Token.pp_spanned tok
+
+
let show_event evt =
+
Format.asprintf "%a" Event.pp_spanned evt
+
+
let test_2jqs () =
+
Printf.printf "\n=== Test 2JQS: Block Mapping with Missing Keys ===\n";
+
let yaml = ": a\n: b" in
+
Printf.printf "Input:\n%s\n\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.peek scanner with
+
| None -> Printf.printf "No more tokens\n"
+
| Some tok ->
+
Printf.printf " %s\n" (show_token tok);
+
ignore (Scanner.next scanner);
+
print_tokens ()
+
in
+
print_tokens ();
+
Printf.printf "\nParsing:\n";
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> Printf.printf "No more events\n"
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let test_5nyz () =
+
Printf.printf "\n=== Test 5NYZ: Separated Comment ===\n";
+
let yaml = "key: # Comment\n value" in
+
Printf.printf "Input:\n%s\n\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.peek scanner with
+
| None -> Printf.printf "No more tokens\n"
+
| Some tok ->
+
Printf.printf " %s\n" (show_token tok);
+
ignore (Scanner.next scanner);
+
print_tokens ()
+
in
+
print_tokens ();
+
Printf.printf "\nParsing:\n";
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> Printf.printf "No more events\n"
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let () =
+
test_2jqs ();
+
test_5nyz ()
+73
yaml/ocaml-yamle/tests/debug_flow.ml
···
+
(* Debug flow context issues *)
+
open Yamle
+
+
let show_error_kind = function
+
| Error.Unexpected_character c -> Printf.sprintf "Unexpected_character(%c)" c
+
| Error.Unexpected_eof -> "Unexpected_eof"
+
| Error.Invalid_escape_sequence s -> Printf.sprintf "Invalid_escape_sequence(%s)" s
+
| Error.Invalid_unicode_escape s -> Printf.sprintf "Invalid_unicode_escape(%s)" s
+
| Error.Invalid_hex_escape s -> Printf.sprintf "Invalid_hex_escape(%s)" s
+
| Error.Invalid_tag s -> Printf.sprintf "Invalid_tag(%s)" s
+
| Error.Invalid_anchor s -> Printf.sprintf "Invalid_anchor(%s)" s
+
| Error.Invalid_alias s -> Printf.sprintf "Invalid_alias(%s)" s
+
| Error.Invalid_comment -> "Invalid_comment"
+
| Error.Unclosed_single_quote -> "Unclosed_single_quote"
+
| Error.Unclosed_double_quote -> "Unclosed_double_quote"
+
| Error.Unclosed_flow_sequence -> "Unclosed_flow_sequence"
+
| Error.Unclosed_flow_mapping -> "Unclosed_flow_mapping"
+
| Error.Invalid_indentation (exp, got) -> Printf.sprintf "Invalid_indentation(expected %d, got %d)" exp got
+
| Error.Invalid_flow_indentation -> "Invalid_flow_indentation"
+
| Error.Tab_in_indentation -> "Tab_in_indentation"
+
| Error.Invalid_block_scalar_header s -> Printf.sprintf "Invalid_block_scalar_header(%s)" s
+
| Error.Invalid_directive s -> Printf.sprintf "Invalid_directive(%s)" s
+
| Error.Invalid_yaml_version s -> Printf.sprintf "Invalid_yaml_version(%s)" s
+
| Error.Invalid_tag_directive s -> Printf.sprintf "Invalid_tag_directive(%s)" s
+
| Error.Reserved_directive s -> Printf.sprintf "Reserved_directive(%s)" s
+
| Error.Unexpected_token s -> Printf.sprintf "Unexpected_token(%s)" s
+
| Error.Expected_document_start -> "Expected_document_start"
+
| Error.Expected_document_end -> "Expected_document_end"
+
| Error.Expected_block_entry -> "Expected_block_entry"
+
| Error.Expected_key -> "Expected_key"
+
| Error.Expected_value -> "Expected_value"
+
| Error.Expected_node -> "Expected_node"
+
| Error.Expected_scalar -> "Expected_scalar"
+
| Error.Expected_sequence_end -> "Expected_sequence_end"
+
| Error.Expected_mapping_end -> "Expected_mapping_end"
+
| Error.Duplicate_anchor s -> Printf.sprintf "Duplicate_anchor(%s)" s
+
| Error.Undefined_alias s -> Printf.sprintf "Undefined_alias(%s)" s
+
| Error.Alias_cycle s -> Printf.sprintf "Alias_cycle(%s)" s
+
| Error.Multiple_documents -> "Multiple_documents"
+
| Error.Mapping_key_too_long -> "Mapping_key_too_long"
+
| Error.Custom s -> Printf.sprintf "Custom(%s)" s
+
| _ -> "Unknown error"
+
+
let test_case id yaml =
+
Printf.printf "\n=== Test %s ===\n%!" id;
+
Printf.printf "YAML: %S\n%!" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "SUCCESS - got %d events\n%!" (List.length events)
+
with Error.Yamle_error err ->
+
let pos_str = match err.Error.span with
+
| Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column
+
| None -> ""
+
in
+
Printf.printf "ERROR%s: %s\n%!" pos_str (show_error_kind err.Error.kind)
+
+
let () =
+
(* Test 87E4: Single Quoted Implicit Keys *)
+
test_case "87E4" {|'implicit block key' : [
+
'implicit flow key' : value,
+
]|};
+
+
(* Test CFD4: Empty implicit key *)
+
test_case "CFD4" {|- [ : empty key ]|};
+
+
(* Test L9U5: Plain Implicit Keys *)
+
test_case "L9U5" {|implicit block key : [
+
implicit flow key : value,
+
]|};
+
+
(* Test 9MMW: Single Pair Implicit Entries *)
+
test_case "9MMW" {|- [ YAML : separate ]|};
+61
yaml/ocaml-yamle/tests/debug_flow2.ml
···
+
(* Debug tokenization *)
+
open Yamle
+
+
let show_token = function
+
| Token.Stream_start enc -> Printf.sprintf "Stream_start(%s)" (match enc with Utf8 -> "UTF8" | _ -> "?")
+
| Token.Stream_end -> "Stream_end"
+
| Token.Document_start -> "Document_start"
+
| Token.Document_end -> "Document_end"
+
| Token.Block_mapping_start -> "Block_mapping_start"
+
| Token.Block_sequence_start -> "Block_sequence_start"
+
| Token.Block_end -> "Block_end"
+
| Token.Flow_sequence_start -> "Flow_sequence_start"
+
| Token.Flow_sequence_end -> "Flow_sequence_end"
+
| Token.Flow_mapping_start -> "Flow_mapping_start"
+
| Token.Flow_mapping_end -> "Flow_mapping_end"
+
| Token.Block_entry -> "Block_entry"
+
| Token.Flow_entry -> "Flow_entry"
+
| Token.Key -> "Key"
+
| Token.Value -> "Value"
+
| Token.Alias s -> Printf.sprintf "Alias(%s)" s
+
| Token.Anchor s -> Printf.sprintf "Anchor(%s)" s
+
| Token.Tag {handle; suffix} -> Printf.sprintf "Tag(%s, %s)" handle suffix
+
| Token.Scalar {value; style; _} ->
+
let style_str = match style with
+
| Plain -> "Plain" | Single_quoted -> "Single" | Double_quoted -> "Double"
+
| Literal -> "Literal" | Folded -> "Folded" | _ -> "Other"
+
in
+
Printf.sprintf "Scalar(%S, %s)" value style_str
+
| _ -> "Other"
+
+
let test_case id yaml =
+
Printf.printf "\n=== Test %s ===\n%!" id;
+
Printf.printf "YAML: %S\n%!" yaml;
+
Printf.printf "Tokens:\n%!";
+
try
+
let scanner = Scanner.of_string yaml in
+
let rec print_tokens () =
+
match Scanner.next scanner with
+
| Some tok ->
+
Printf.printf " %s at line %d col %d\n%!"
+
(show_token tok.token)
+
tok.span.start.line
+
tok.span.start.column;
+
print_tokens ()
+
| None -> ()
+
in
+
print_tokens ();
+
Printf.printf "SUCCESS\n%!"
+
with Error.Yamle_error err ->
+
let pos_str = match err.Error.span with
+
| Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column
+
| None -> ""
+
in
+
Printf.printf "ERROR%s\n%!" pos_str
+
+
let () =
+
(* Test CFD4: Empty implicit key *)
+
test_case "CFD4" {|- [ : empty key ]|};
+
+
(* Test 9MMW: Single Pair Implicit Entries *)
+
test_case "9MMW" {|- [ YAML : separate ]|};
+27
yaml/ocaml-yamle/tests/debug_flow3.ml
···
+
open Yamle
+
+
let show_error_kind = function
+
| Error.Expected_sequence_end -> "Expected_sequence_end"
+
| Error.Expected_mapping_end -> "Expected_mapping_end"
+
| Error.Unexpected_token s -> Printf.sprintf "Unexpected_token(%s)" s
+
| Error.Expected_key -> "Expected_key"
+
| Error.Expected_value -> "Expected_value"
+
| Error.Expected_node -> "Expected_node"
+
| _ -> "Other"
+
+
let test yaml =
+
Printf.printf "YAML: %S\n%!" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "SUCCESS - %d events\n%!" (List.length events)
+
with Error.Yamle_error err ->
+
let pos_str = match err.Error.span with
+
| Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column
+
| None -> ""
+
in
+
Printf.printf "ERROR%s: %s\n%!" pos_str (show_error_kind err.Error.kind)
+
+
let () =
+
test {|- [ : empty key ]|};
+
test {|- [ YAML : separate ]|};
+36
yaml/ocaml-yamle/tests/debug_flow4.ml
···
+
open Yamle
+
+
let test yaml =
+
Printf.printf "\n=== YAML: %S ===\n%!" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let rec print_events n =
+
match Parser.next parser with
+
| None -> Printf.printf "Total events: %d\n%!" n
+
| Some ev ->
+
Printf.printf "Event %d: " n;
+
(match ev.Event.event with
+
| Event.Stream_start _ -> Printf.printf "Stream_start\n"
+
| Event.Stream_end -> Printf.printf "Stream_end\n"
+
| Event.Document_start _ -> Printf.printf "Document_start\n"
+
| Event.Document_end _ -> Printf.printf "Document_end\n"
+
| Event.Sequence_start _ -> Printf.printf "Sequence_start\n"
+
| Event.Sequence_end -> Printf.printf "Sequence_end\n"
+
| Event.Mapping_start _ -> Printf.printf "Mapping_start\n"
+
| Event.Mapping_end -> Printf.printf "Mapping_end\n"
+
| Event.Scalar {value; _} -> Printf.printf "Scalar(%S)\n" value
+
| Event.Alias {anchor} -> Printf.printf "Alias(%s)\n" anchor);
+
print_events (n + 1)
+
in
+
print_events 0;
+
Printf.printf "SUCCESS\n%!"
+
with Error.Yamle_error err ->
+
let pos_str = match err.Error.span with
+
| Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column
+
| None -> ""
+
in
+
Printf.printf "ERROR%s\n%!" pos_str
+
+
let () =
+
test {|- [ : empty key ]|};
+
test {|- [ YAML : separate ]|};
+29
yaml/ocaml-yamle/tests/debug_flow5.ml
···
+
open Yamle
+
+
let () =
+
Printf.printf "Test: - [ : empty key ]\n%!";
+
try
+
let scanner = Scanner.of_string {|- [ : empty key ]|} in
+
Printf.printf "Tokens:\n%!";
+
let rec print_all n =
+
match Scanner.next scanner with
+
| None -> ()
+
| Some tok ->
+
Printf.printf " %d. " n;
+
(match tok.Token.token with
+
| Token.Stream_start _ -> Printf.printf "Stream_start"
+
| Token.Stream_end -> Printf.printf "Stream_end"
+
| Token.Block_sequence_start -> Printf.printf "Block_sequence_start"
+
| Token.Block_entry -> Printf.printf "Block_entry"
+
| Token.Block_end -> Printf.printf "Block_end"
+
| Token.Flow_sequence_start -> Printf.printf "Flow_sequence_start"
+
| Token.Flow_sequence_end -> Printf.printf "Flow_sequence_end"
+
| Token.Value -> Printf.printf "Value"
+
| Token.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
+
| _ -> Printf.printf "Other");
+
Printf.printf " at %d:%d\n%!" tok.span.start.line tok.span.start.column;
+
print_all (n + 1)
+
in
+
print_all 0
+
with Error.Yamle_error _ ->
+
Printf.printf "Scanner error\n%!"
+19
yaml/ocaml-yamle/tests/debug_flow6.ml
···
+
open Yamle
+
+
let () =
+
Printf.printf "Test: - [ a ]\n%!";
+
let parser = Parser.of_string {|- [ a ]|} in
+
let rec print_events n =
+
match Parser.next parser with
+
| None -> ()
+
| Some ev ->
+
Printf.printf "%d: " n;
+
(match ev.Event.event with
+
| Event.Sequence_start _ -> Printf.printf "Sequence_start"
+
| Event.Sequence_end -> Printf.printf "Sequence_end"
+
| Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
+
| _ -> Printf.printf "Other");
+
Printf.printf "\n%!";
+
print_events (n + 1)
+
in
+
print_events 0
+30
yaml/ocaml-yamle/tests/debug_flow7.ml
···
+
open Yamle
+
+
let test yaml =
+
Printf.printf "\nYAML: %S\n%!" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let rec print_events n =
+
match Parser.next parser with
+
| None -> Printf.printf "Total: %d events\n" n
+
| Some ev ->
+
Printf.printf "%d: " n;
+
(match ev.Event.event with
+
| Event.Sequence_start _ -> Printf.printf "Sequence_start"
+
| Event.Sequence_end -> Printf.printf "Sequence_end"
+
| Event.Mapping_start _ -> Printf.printf "Mapping_start"
+
| Event.Mapping_end -> Printf.printf "Mapping_end"
+
| Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
+
| _ -> Printf.printf "Other");
+
Printf.printf "\n%!";
+
print_events (n + 1)
+
in
+
print_events 0;
+
Printf.printf "SUCCESS\n%!"
+
with Error.Yamle_error _ ->
+
Printf.printf "ERROR\n%!"
+
+
let () =
+
test {|[a, b]|}; (* Simple flow sequence *)
+
test {|[{a: b}]|}; (* Flow sequence with mapping *)
+
test {|[a: b]|}; (* Flow sequence with implicit mapping *)
+23
yaml/ocaml-yamle/tests/debug_from.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "---\n- name: Spec Example 2.4. Sequence of Mappings\n from: http://example.com\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop count =
+
if count > 30 then Printf.printf " ... (stopped at 30 tokens)\n"
+
else match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop (count + 1)
+
in
+
loop 0
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e);
+
Printexc.print_backtrace stdout
+22
yaml/ocaml-yamle/tests/debug_jef9.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
open Yamle
+
+
let () =
+
let tests = TL.load_file "../yaml-test-suite/src/JEF9.yaml" in
+
List.iter (fun (test : TL.test_case) ->
+
Printf.printf "=== Test: %s ===\n" test.id;
+
Printf.printf "YAML bytes: ";
+
String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml;
+
Printf.printf "\n";
+
Printf.printf "YAML len: %d\n" (String.length test.yaml);
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events);
+
let tree = TF.of_spanned_events events in
+
Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
+
Printf.printf "Actual tree:\n%s\n" tree
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
) tests
+23
yaml/ocaml-yamle/tests/debug_l24t.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
open Yamle
+
+
let () =
+
let tests = TL.load_file "../yaml-test-suite/src/L24T.yaml" in
+
List.iter (fun (test : TL.test_case) ->
+
Printf.printf "=== Test: %s ===\n" test.id;
+
Printf.printf "YAML bytes: ";
+
String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml;
+
Printf.printf "\n";
+
Printf.printf "YAML repr: %S\n" test.yaml;
+
Printf.printf "YAML len: %d\n" (String.length test.yaml);
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events);
+
let tree = TF.of_spanned_events events in
+
Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
+
Printf.printf "Actual tree:\n%s\n" tree
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
) tests
+28
yaml/ocaml-yamle/tests/debug_m2n8.ml
···
+
open Yamle
+
module TF = Test_suite_lib.Tree_format
+
+
let () =
+
let yaml = "- ? : x\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
Printf.printf "\nExpected tree:\n";
+
Printf.printf "+STR
+
+DOC
+
+SEQ
+
+MAP
+
+MAP
+
=VAL :
+
=VAL :x
+
-MAP
+
=VAL :
+
-MAP
+
-SEQ
+
-DOC
+
-STR\n";
+
Printf.printf "\nParsing:\n";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
let tree = TF.of_spanned_events events in
+
Printf.printf "Actual tree:\n%s\n" tree
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+83
yaml/ocaml-yamle/tests/debug_multiline.ml
···
+
(* Debug specific multiline tests *)
+
open Yamle
+
+
let show_event evt =
+
Format.asprintf "%a" Event.pp_spanned evt
+
+
let test_a984 () =
+
let yaml = "a: b\n c\nd:\n e\n f" in
+
Printf.printf "Testing A984 (Multiline Scalar in Mapping):\n%s\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
Printf.printf "Events:\n";
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> ()
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let test_v9d5 () =
+
let yaml = "- sun: yellow\n- ? earth: blue\n : moon: white" in
+
Printf.printf "\nTesting V9D5 (Compact Block Mappings):\n%s\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
Printf.printf "Events:\n";
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> ()
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let test_q9wf () =
+
let yaml = "{ first: Sammy, last: Sosa }:\n# Statistics:\n hr: # Home runs\n 65\n avg: # Average\n 0.278" in
+
Printf.printf "\nTesting Q9WF (Separation Spaces):\n%s\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
Printf.printf "Events:\n";
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> ()
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let test_m2n8 () =
+
let yaml = "- ? : x" in
+
Printf.printf "\nTesting M2N8 (Question mark edge cases):\n%s\n" yaml;
+
try
+
let scanner = Scanner.of_string yaml in
+
let parser = Parser.create scanner in
+
Printf.printf "Events:\n";
+
let rec print_events () =
+
match Parser.next parser with
+
| None -> ()
+
| Some event ->
+
Printf.printf " %s\n" (show_event event);
+
print_events ()
+
in
+
print_events ()
+
with e ->
+
Printf.printf "ERROR: %s\n" (Printexc.to_string e)
+
+
let () =
+
test_a984 ();
+
test_v9d5 ();
+
test_q9wf ();
+
test_m2n8 ()
+12
yaml/ocaml-yamle/tests/debug_mus6_01.ml
···
+
open Yamle
+
let () =
+
let yaml = "%YAML 1.2\n---\n%YAML 1.2\n---\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+7
yaml/ocaml-yamle/tests/debug_mus6_load.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
+
let () =
+
let tests = TL.load_file "../yaml-test-suite/src/MUS6.yaml" in
+
List.iter (fun t ->
+
Printf.printf "ID: %s, fail: %b, yaml: %S\n" t.TL.id t.TL.fail t.TL.yaml
+
) tests
+41
yaml/ocaml-yamle/tests/debug_prh3.ml
···
+
(* Debug PRH3 specifically *)
+
open Yamle
+
+
let yaml = "' 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty '"
+
+
let () =
+
Printf.printf "Input YAML:\n";
+
for i = 0 to String.length yaml - 1 do
+
let c = yaml.[i] in
+
match c with
+
| '\n' -> Printf.printf "\\n"
+
| '\t' -> Printf.printf "\\t"
+
| ' ' -> Printf.printf "·"
+
| _ -> Printf.printf "%c" c
+
done;
+
Printf.printf "\n\n";
+
+
Printf.printf "Expected: ' 1st non-empty\\n2nd non-empty 3rd non-empty '\n";
+
Printf.printf "Expected (visual): '·1st·non-empty\\n2nd·non-empty·3rd·non-empty·'\n\n";
+
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
List.iter (fun (e : Event.spanned) ->
+
match e.event with
+
| Event.Scalar { value; _ } ->
+
Printf.printf "Actual scalar value:\n";
+
for i = 0 to String.length value - 1 do
+
let c = value.[i] in
+
match c with
+
| '\n' -> Printf.printf "\\n"
+
| '\t' -> Printf.printf "\\t"
+
| ' ' -> Printf.printf "·"
+
| _ -> Printf.printf "%c" c
+
done;
+
Printf.printf "\n";
+
Printf.printf "Length: %d\n" (String.length value)
+
| _ -> ()
+
) events
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+42
yaml/ocaml-yamle/tests/debug_quoted.ml
···
+
(* Debug quoted string issues *)
+
open Yamle
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
+
let test_suite_path = "../yaml-test-suite"
+
+
let () =
+
let src_path = Filename.concat test_suite_path "src" in
+
let all_tests = TL.load_directory src_path in
+
+
(* Filter for specific tests *)
+
let tests = List.filter (fun t ->
+
t.TL.id = "PRH3" || t.TL.id = "T4YY" || t.TL.id = "NAT4"
+
) all_tests in
+
+
List.iter (fun test ->
+
Printf.printf "\n=== %s: %s ===\n" test.TL.id test.TL.name;
+
Printf.printf "YAML input:\n%s\n" (String.escaped test.TL.yaml);
+
Printf.printf "YAML (raw):\n%s\n---\n" test.TL.yaml;
+
+
match test.TL.tree with
+
| None -> Printf.printf "No expected tree\n"
+
| Some expected ->
+
Printf.printf "Expected tree:\n%s\n" expected;
+
+
(try
+
let parser = Parser.of_string test.TL.yaml in
+
let events = Parser.to_list parser in
+
let actual = TF.of_spanned_events events in
+
Printf.printf "Actual tree:\n%s\n" actual;
+
+
(* Show scalar values *)
+
List.iter (fun (e : Event.spanned) ->
+
match e.event with
+
| Event.Scalar { value; _ } ->
+
Printf.printf "Scalar value: %s (len=%d)\n" (String.escaped value) (String.length value)
+
| _ -> ()
+
) events;
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e))
+
) tests
+23
yaml/ocaml-yamle/tests/debug_r4yg.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
open Yamle
+
+
let () =
+
let tests = TL.load_file "../yaml-test-suite/src/R4YG.yaml" in
+
List.iter (fun (test : TL.test_case) ->
+
Printf.printf "=== Test: %s ===\n" test.id;
+
Printf.printf "YAML bytes: ";
+
String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml;
+
Printf.printf "\n";
+
Printf.printf "YAML repr: %S\n" test.yaml;
+
Printf.printf "YAML len: %d\n" (String.length test.yaml);
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events);
+
let tree = TF.of_spanned_events events in
+
Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
+
Printf.printf "Actual tree:\n%s\n" tree
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
) tests
+39
yaml/ocaml-yamle/tests/debug_v9d5.ml
···
+
open Yamle
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
+
let () =
+
let tests = TL.load_file "../yaml-test-suite/src/V9D5.yaml" in
+
List.iter (fun (test : TL.test_case) ->
+
Printf.printf "=== Test: %s ===\n" test.id;
+
Printf.printf "YAML: %S\n" test.yaml;
+
+
(* Print tokens *)
+
Printf.printf "\nTokens:\n";
+
let scanner = Scanner.of_string test.yaml in
+
begin try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Scanner error: %s\n" (Printexc.to_string e)
+
end;
+
+
Printf.printf "\nExpected tree:\n%s\n" (Option.value ~default:"(none)" test.tree);
+
Printf.printf "\nParsing:\n";
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
let tree = TF.of_spanned_events events in
+
Printf.printf "Actual tree:\n%s\n" tree
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
) tests
+13
yaml/ocaml-yamle/tests/debug_y79y_03.ml
···
+
open Yamle
+
let () =
+
(* Y79Y/03: - [<nl><tab>foo,<nl> foo<nl> ] *)
+
let yaml = "- [\n\tfoo,\n foo\n ]" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+13
yaml/ocaml-yamle/tests/debug_y79y_09.ml
···
+
open Yamle
+
let () =
+
(* Y79Y/09: ? key:<nl>:<tab>key: *)
+
let yaml = "? key:\n:\tkey:" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+13
yaml/ocaml-yamle/tests/debug_y79y_first.ml
···
+
open Yamle
+
let () =
+
(* Y79Y first test: block scalar followed by tab-only line *)
+
let yaml = "foo: |\n\t\nbar: 1\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+70
yaml/ocaml-yamle/tests/run_all_tests.ml
···
+
(* Run all yaml-test-suite tests *)
+
open Yamle
+
module TL = Test_suite_lib.Test_suite_loader
+
module TF = Test_suite_lib.Tree_format
+
+
let test_suite_path = "../yaml-test-suite"
+
+
let normalize_tree s =
+
let lines = String.split_on_char '\n' s in
+
let lines = List.filter (fun l -> String.trim l <> "") lines in
+
String.concat "\n" lines
+
+
let run_test (test : TL.test_case) =
+
if test.fail then begin
+
try
+
let parser = Parser.of_string test.yaml in
+
let _events = Parser.to_list parser in
+
`Fail "Expected parsing to fail"
+
with
+
| Yamle_error _ -> `Pass
+
| _ -> `Pass
+
end
+
else begin
+
match test.tree with
+
| None -> `Skip
+
| Some expected ->
+
try
+
let parser = Parser.of_string test.yaml in
+
let events = Parser.to_list parser in
+
let actual = TF.of_spanned_events events in
+
let expected_norm = normalize_tree expected in
+
let actual_norm = normalize_tree actual in
+
if expected_norm = actual_norm then `Pass
+
else begin
+
let msg = Printf.sprintf "Tree mismatch:\nExpected:\n%s\nActual:\n%s" expected_norm actual_norm in
+
`Fail msg
+
end
+
with e ->
+
let msg = Printexc.to_string e in
+
`Fail (Printf.sprintf "Exception: %s" msg)
+
end
+
+
let () =
+
let src_path = Filename.concat test_suite_path "src" in
+
let all_tests = TL.load_directory src_path in
+
Printf.printf "Total tests loaded: %d\n%!" (List.length all_tests);
+
+
let pass = ref 0 in
+
let fail = ref 0 in
+
let skip = ref 0 in
+
let failures = ref [] in
+
+
List.iter (fun test ->
+
match run_test test with
+
| `Pass -> incr pass
+
| `Skip -> incr skip
+
| `Fail msg ->
+
incr fail;
+
failures := (test.TL.id, test.TL.name, msg) :: !failures
+
) all_tests;
+
+
Printf.printf "\nResults: %d pass, %d fail, %d skip (total: %d)\n%!"
+
!pass !fail !skip (!pass + !fail + !skip);
+
+
if !fail > 0 then begin
+
Printf.printf "\nFailing tests:\n";
+
List.iter (fun (id, name, _msg) ->
+
Printf.printf " %s: %s\n" id name
+
) (List.rev !failures)
+
end
+23
yaml/ocaml-yamle/tests/test_229q_direct.ml
···
+
open Yamle
+
+
let () =
+
let yaml = In_channel.with_open_text "../yaml-test-suite/src/229Q.yaml" In_channel.input_all in
+
Printf.printf "YAML length: %d\n" (String.length yaml);
+
Printf.printf "First 200 chars: %S\n" (String.sub yaml 0 (min 200 (String.length yaml)));
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop count =
+
if count > 30 then Printf.printf " ... (stopped at 30 tokens)\n"
+
else match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop (count + 1)
+
in
+
loop 0
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+12
yaml/ocaml-yamle/tests/test_2cms.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "this\n is\n invalid: x\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
Printf.printf "\nParsing:\n";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d (should have errored)\n" (List.length events)
+
with e ->
+
Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
+18
yaml/ocaml-yamle/tests/test_2cms_quick.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "this\n is\n invalid: x\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
Format.printf "Parsing:@.";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e ->
+
Format.printf " %a@." Event.pp e.Event.event
+
) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+
| e ->
+
Format.printf "Error: %s@." (Printexc.to_string e)
+25
yaml/ocaml-yamle/tests/test_3hfz.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "---\nkey: value\n... invalid\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
Printf.printf "Byte 18: %C (space=%b, break=%b)\n"
+
yaml.[18]
+
(yaml.[18] = ' ' || yaml.[18] = '\t')
+
(yaml.[18] = '\n' || yaml.[18] = '\r');
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+29
yaml/ocaml-yamle/tests/test_565n_debug.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "generic: !!binary |
+
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
+
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
+
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
+
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" in
+
+
let scanner = Scanner.of_string yaml in
+
let rec find_binary () =
+
match Scanner.next scanner with
+
| None -> None
+
| Some { token; _ } ->
+
match token with
+
| Token.Scalar { style = Scalar_style.Literal; value; _ } -> Some value
+
| _ -> find_binary ()
+
in
+
match find_binary () with
+
| None -> Printf.printf "No literal scalar found\n"
+
| Some value ->
+
Printf.printf "Got: %S\n" value;
+
Printf.printf "First char: %C (code %d)\n" value.[0] (Char.code value.[0]);
+
if value.[0] = ' ' then
+
Printf.printf "FAIL: starts with space\n"
+
else if value.[0] = 'R' then
+
Printf.printf "PASS: starts with R\n"
+
else
+
Printf.printf "FAIL: starts with unexpected char\n"
+17
yaml/ocaml-yamle/tests/test_5llu_quick.ml
···
+
open Yamle
+
(* Test 5LLU: Block scalar with wrong indented line after spaces only *)
+
let () =
+
(* block scalar: >
+
␣ (1 space, empty line)
+
␣␣ (2 spaces, empty line)
+
␣␣␣ (3 spaces, empty line)
+
invalid (1 space + content - ERROR!) *)
+
let yaml = "block scalar: >\n \n \n \n invalid\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events)
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+11
yaml/ocaml-yamle/tests/test_5u3a.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "key: - a\n - b\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d (should have errored)\n" (List.length events)
+
with e ->
+
Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
+29
yaml/ocaml-yamle/tests/test_6vjk_debug.ml
···
+
open Yamle
+
+
let () =
+
let yaml = ">
+
Sammy Sosa completed another
+
fine season with great stats.
+
+
63 Home Runs
+
0.288 Batting Average
+
+
What a year!" in
+
Printf.printf "Input YAML:\n%s\n\n" yaml;
+
+
(* Create scanner and get scalar token *)
+
let scanner = Scanner.of_string yaml in
+
let rec find_scalar () =
+
match Scanner.next scanner with
+
| None -> failwith "No scalar found"
+
| Some { token; _ } ->
+
match token with
+
| Token.Scalar (style, value) ->
+
Printf.printf "Scalar value: %S\n" value;
+
Printf.printf "Style: %s\n" (match style with
+
| Scalar_style.Literal -> "Literal"
+
| Scalar_style.Folded -> "Folded"
+
| _ -> "Other")
+
| _ -> find_scalar ()
+
in
+
find_scalar ()
+31
yaml/ocaml-yamle/tests/test_6vjk_only.ml
···
+
open Yamle
+
+
let () =
+
let yaml = ">
+
Sammy Sosa completed another
+
fine season with great stats.
+
+
63 Home Runs
+
0.288 Batting Average
+
+
What a year!" in
+
+
let scanner = Scanner.of_string yaml in
+
let rec find_scalar () =
+
match Scanner.next scanner with
+
| None -> None
+
| Some { token; _ } ->
+
match token with
+
| Token.Scalar { style = _; value } -> Some value
+
| _ -> find_scalar ()
+
in
+
match find_scalar () with
+
| None -> Printf.printf "No scalar found\n"
+
| Some value ->
+
Printf.printf "Got: %S\n" value;
+
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
+
Printf.printf "Expected: %S\n" expected;
+
if value = expected then
+
Printf.printf "PASS\n"
+
else
+
Printf.printf "FAIL\n"
+25
yaml/ocaml-yamle/tests/test_87e4.ml
···
+
open Yamle
+
+
let yaml = {|'implicit block key' : [
+
'implicit flow key' : value,
+
]|}
+
+
let () =
+
Printf.printf "Testing 87E4\n";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Parsed successfully with %d events\n" (List.length events);
+
List.iteri (fun i ev ->
+
Printf.printf "Event %d: " i;
+
(match ev.Event.event with
+
| Event.Sequence_start _ -> Printf.printf "Sequence_start"
+
| Event.Sequence_end -> Printf.printf "Sequence_end"
+
| Event.Mapping_start _ -> Printf.printf "Mapping_start"
+
| Event.Mapping_end -> Printf.printf "Mapping_end"
+
| Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
+
| _ -> Printf.printf "Other");
+
Printf.printf "\n"
+
) events
+
with Error.Yamle_error _ ->
+
Printf.printf "ERROR\n"
+14
yaml/ocaml-yamle/tests/test_a984_minimal.ml
···
+
open Yamle
+
+
let test yaml =
+
Printf.printf "YAML:\n%s\n\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
try
+
while Scanner.next scanner <> None do () done;
+
Printf.printf "Success!\n"
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
+
let () =
+
test "d:\n e";
+
test "a: b\n c\nd:\n e\n f"
+20
yaml/ocaml-yamle/tests/test_a984_trace.ml
···
+
(* Trace A984 issue *)
+
open Yamle
+
+
let show_token tok =
+
Format.asprintf "%a" Token.pp_spanned tok
+
+
let () =
+
let yaml = "a: b\n c\nd:\n e\n f" in
+
Printf.printf "Testing A984:\n%s\n\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.peek scanner with
+
| None -> Printf.printf "Done\n"
+
| Some tok ->
+
Printf.printf " %s\n" (show_token tok);
+
ignore (Scanner.next scanner);
+
print_tokens ()
+
in
+
print_tokens ()
+19
yaml/ocaml-yamle/tests/test_all_mentioned_cases.ml
···
+
open Yamle
+
+
let test name yaml =
+
Printf.printf "\n=== %s ===\n" name;
+
let scanner = Scanner.of_string yaml in
+
try
+
while Scanner.next scanner <> None do () done;
+
Printf.printf "PASS\n"
+
with e ->
+
Printf.printf "FAIL: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* All cases mentioned in the issue *)
+
test "565N - Construct Binary" "generic: !!binary |\n R0lGODlh";
+
test "A984 - Multiline Scalar" "a: b\n c\nd:\n e\n f";
+
test "RZP5 - Trailing Comments" "- #lala\n seq2";
+
test "XW4D - Trailing Comments variant" "- #comment\n value";
+
test "Q9WF - Separation Spaces" "a: -\tb";
+
test "V9D5 - Compact Block Mappings" "- a: b"
+167
yaml/ocaml-yamle/tests/test_anchor_tag_issues.ml
···
+
(** Test cases for BU8L, SKE5, RZP5, XW4D *)
+
+
let print_token tok =
+
match tok.Yamle.Token.token with
+
| Yamle.Token.Stream_start _ -> "Stream_start"
+
| Yamle.Token.Stream_end -> "Stream_end"
+
| Yamle.Token.Document_start -> "Document_start"
+
| Yamle.Token.Document_end -> "Document_end"
+
| Yamle.Token.Block_sequence_start -> "Block_sequence_start"
+
| Yamle.Token.Block_mapping_start -> "Block_mapping_start"
+
| Yamle.Token.Block_end -> "Block_end"
+
| Yamle.Token.Flow_sequence_start -> "Flow_sequence_start"
+
| Yamle.Token.Flow_sequence_end -> "Flow_sequence_end"
+
| Yamle.Token.Flow_mapping_start -> "Flow_mapping_start"
+
| Yamle.Token.Flow_mapping_end -> "Flow_mapping_end"
+
| Yamle.Token.Block_entry -> "Block_entry"
+
| Yamle.Token.Flow_entry -> "Flow_entry"
+
| Yamle.Token.Key -> "Key"
+
| Yamle.Token.Value -> "Value"
+
| Yamle.Token.Alias name -> "Alias(" ^ name ^ ")"
+
| Yamle.Token.Anchor name -> "Anchor(" ^ name ^ ")"
+
| Yamle.Token.Tag { handle; suffix } -> "Tag(" ^ handle ^ suffix ^ ")"
+
| Yamle.Token.Scalar { value; _ } -> "Scalar(" ^ String.sub value 0 (min 20 (String.length value)) ^ ")"
+
| Yamle.Token.Version_directive _ -> "Version_directive"
+
| Yamle.Token.Tag_directive _ -> "Tag_directive"
+
+
let test_bu8l () =
+
print_endline "Testing BU8L: Node Anchor and Tag on Separate Lines";
+
let yaml = {|key: &anchor
+
!!map
+
a: b|} in
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let rec print_tokens n =
+
if n > 30 then (print_endline " ... (stopped at 30 tokens)"; ())
+
else
+
try
+
match Yamle.Scanner.peek scanner with
+
| Some { token = Stream_end; _ } as tok ->
+
Printf.printf " %s\n" (print_token (Option.get tok));
+
ignore (Yamle.Scanner.next scanner);
+
()
+
| Some tok ->
+
Printf.printf " %s\n" (print_token tok);
+
ignore (Yamle.Scanner.next scanner);
+
print_tokens (n + 1)
+
| None -> print_endline " (no more tokens)"
+
with
+
| Yamle.Error.Yamle_error e ->
+
Printf.printf " ERROR during scan: %s\n" (Yamle.Error.to_string e);
+
raise (Yamle.Error.Yamle_error e)
+
in
+
print_tokens 0;
+
print_endline "BU8L: Scanner SUCCESS\n"
+
with
+
| Yamle.Error.Yamle_error e ->
+
Printf.printf "BU8L: FAILED with %s\n\n" (Yamle.Error.to_string e)
+
| e ->
+
Printf.printf "BU8L: FAILED with %s\n\n" (Printexc.to_string e)
+
+
let test_ske5 () =
+
print_endline "Testing SKE5: Anchor before zero indented sequence";
+
let yaml = {|---
+
seq:
+
&anchor
+
- a
+
- b|} in
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let rec count_tokens n =
+
match Yamle.Scanner.peek scanner with
+
| Some { token = Stream_end; _ } ->
+
ignore (Yamle.Scanner.next scanner);
+
n
+
| Some _ ->
+
ignore (Yamle.Scanner.next scanner);
+
count_tokens (n + 1)
+
| None -> n
+
in
+
let count = count_tokens 0 in
+
Printf.printf "SKE5: SUCCESS (tokens: %d)\n\n" count
+
with
+
| Yamle.Error.Yamle_error e ->
+
Printf.printf "SKE5: FAILED with %s\n\n" (Yamle.Error.to_string e)
+
| e ->
+
Printf.printf "SKE5: FAILED with %s\n\n" (Printexc.to_string e)
+
+
let test_rzp5 () =
+
print_endline "Testing RZP5: Various Trailing Comments [1.3]";
+
let yaml = {|a: "double
+
quotes" # lala
+
b: plain
+
value # lala
+
c : #lala
+
d
+
? # lala
+
- seq1
+
: # lala
+
- #lala
+
seq2
+
e: &node # lala
+
- x: y
+
block: > # lala
+
abcde|} in
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let rec count_tokens n =
+
match Yamle.Scanner.peek scanner with
+
| Some { token = Stream_end; _ } ->
+
ignore (Yamle.Scanner.next scanner);
+
n
+
| Some _ ->
+
ignore (Yamle.Scanner.next scanner);
+
count_tokens (n + 1)
+
| None -> n
+
in
+
let count = count_tokens 0 in
+
Printf.printf "RZP5: SUCCESS (tokens: %d)\n\n" count
+
with
+
| Yamle.Error.Yamle_error e ->
+
Printf.printf "RZP5: FAILED with %s\n\n" (Yamle.Error.to_string e)
+
| e ->
+
Printf.printf "RZP5: FAILED with %s\n\n" (Printexc.to_string e)
+
+
let test_xw4d () =
+
print_endline "Testing XW4D: Various Trailing Comments";
+
let yaml = {|a: "double
+
quotes" # lala
+
b: plain
+
value # lala
+
c : #lala
+
d
+
? # lala
+
- seq1
+
: # lala
+
- #lala
+
seq2
+
e:
+
&node # lala
+
- x: y
+
block: > # lala
+
abcde|} in
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let rec count_tokens n =
+
match Yamle.Scanner.peek scanner with
+
| Some { token = Stream_end; _ } ->
+
ignore (Yamle.Scanner.next scanner);
+
n
+
| Some _ ->
+
ignore (Yamle.Scanner.next scanner);
+
count_tokens (n + 1)
+
| None -> n
+
in
+
let count = count_tokens 0 in
+
Printf.printf "XW4D: SUCCESS (tokens: %d)\n\n" count
+
with
+
| Yamle.Error.Yamle_error e ->
+
Printf.printf "XW4D: FAILED with %s\n\n" (Yamle.Error.to_string e)
+
| e ->
+
Printf.printf "XW4D: FAILED with %s\n\n" (Printexc.to_string e)
+
+
let () =
+
test_bu8l ();
+
test_ske5 ();
+
test_rzp5 ();
+
test_xw4d ()
+11
yaml/ocaml-yamle/tests/test_basic_yaml.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "key: value\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events)
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+18
yaml/ocaml-yamle/tests/test_bs4k.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "word1 # comment\nword2\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
Format.printf "Parsing:@.";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e ->
+
Format.printf " %a@." Event.pp e.Event.event
+
) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+
| e ->
+
Format.printf "Error: %s@." (Printexc.to_string e)
+21
yaml/ocaml-yamle/tests/test_debug_stale.ml
···
+
open Yamle
+
+
(* Patch Scanner to add debug output *)
+
let test yaml =
+
Printf.printf "YAML:\n%s\n\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf "Done\n"
+
| Some tok ->
+
Printf.printf "%s\n" (Format.asprintf "%a" Token.pp_spanned tok);
+
loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* This should work: simple key, value on next line *)
+
test "d:\n e"
+21
yaml/ocaml-yamle/tests/test_dk4h.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "---\n[ key\n : value ]\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+9
yaml/ocaml-yamle/tests/test_error_type.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "d:\n e" in
+
let scanner = Scanner.of_string yaml in
+
try
+
while Scanner.next scanner <> None do () done
+
with Error.Yamle_error err ->
+
Printf.printf "Error: %s\n" (Error.to_string err)
+6
yaml/ocaml-yamle/tests/test_indent_debug.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "d:\n e" in
+
let scanner = Scanner.of_string yaml in
+
ignore (Scanner.to_list scanner)
+18
yaml/ocaml-yamle/tests/test_ks4u.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "---\n[\nsequence item\n]\ninvalid item\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
Format.printf "Parsing:@.";
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events);
+
List.iter (fun e ->
+
Format.printf " %a@." Event.pp e.Event.event
+
) events
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+
| e ->
+
Format.printf "Error: %s@." (Printexc.to_string e)
+21
yaml/ocaml-yamle/tests/test_lhl4.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "---\n!invalid{}tag scalar\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+9
yaml/ocaml-yamle/tests/test_loader_debug.ml
···
+
module TL = Test_suite_lib.Test_suite_loader
+
+
let () =
+
Printf.printf "Testing test loader...\n";
+
try
+
let tests = TL.load_file "../yaml-test-suite/src/229Q.yaml" in
+
Printf.printf "Loaded %d tests\n" (List.length tests)
+
with e ->
+
Printf.printf "Error loading: %s\n" (Printexc.to_string e)
+11
yaml/ocaml-yamle/tests/test_mus6_debug.ml
···
+
open Yamle
+
let () =
+
let yaml = "%YAML 1.1#...\n---\n" in
+
Format.printf "YAML: %S@.@." yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
Format.printf "Events: %d (ERROR: should have failed)@." (List.length events)
+
with
+
| Yamle_error e ->
+
Format.printf "Error (expected): %a@." Error.pp e
+47
yaml/ocaml-yamle/tests/test_nat4_a.ml
···
+
(* Test NAT4 case a specifically *)
+
open Yamle
+
+
let test_case desc yaml expected =
+
Printf.printf "\n=== %s ===\n" desc;
+
Printf.printf "Input: %s\n" (String.escaped yaml);
+
try
+
let parser = Parser.of_string yaml in
+
let events = Parser.to_list parser in
+
List.iter (fun (e : Event.spanned) ->
+
match e.event with
+
| Event.Scalar { value; style; _ } ->
+
Printf.printf "Output: %s (len=%d, style=%s)\n"
+
(String.escaped value)
+
(String.length value)
+
(match style with
+
| Scalar_style.Single_quoted -> "single"
+
| Scalar_style.Double_quoted -> "double"
+
| _ -> "other");
+
Printf.printf "Expected: %s (len=%d)\n" (String.escaped expected) (String.length expected);
+
if value = expected then
+
Printf.printf "✓ PASS\n"
+
else
+
Printf.printf "✗ FAIL\n"
+
| _ -> ()
+
) events
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* NAT4 case a: newline then spaces *)
+
test_case "a" "a: '\n '" " ";
+
+
(* NAT4 case b: spaces, newline, spaces *)
+
test_case "b" "a: ' \n '" " ";
+
+
(* NAT4 case e: newline, empty line, spaces *)
+
test_case "e" "a: '\n\n '" "\n";
+
+
(* NAT4 case g: newline, two empty lines, spaces *)
+
test_case "g" "a: '\n\n\n '" "\n\n";
+
+
(* Simple case: text on both lines *)
+
test_case "simple" "a: 'foo\nbar'" "foo bar";
+
+
(* Case with empty line between text *)
+
test_case "empty_between" "a: 'foo\n\nbar'" "foo\nbar";
+31
yaml/ocaml-yamle/tests/test_remaining.ml
···
+
open Yamle
+
+
let test yaml name =
+
Printf.printf "\n=== %s ===\n" name;
+
Printf.printf "YAML: %S\n" yaml;
+
try
+
let parser = Parser.of_string yaml in
+
let _ = Parser.to_list parser in
+
Printf.printf "SUCCESS\n"
+
with Error.Yamle_error _ ->
+
Printf.printf "ERROR\n"
+
+
let () =
+
(* CT4Q: Single Pair Explicit Entry *)
+
test {|[
+
? foo
+
bar : baz
+
]|} "CT4Q";
+
+
(* DFF7: Flow Mapping Entries *)
+
test {|{
+
? explicit: entry,
+
implicit: entry,
+
?
+
}|} "DFF7";
+
+
(* FRK4: Completely Empty Flow Nodes *)
+
test {|{
+
? foo :,
+
: bar,
+
}|} "FRK4";
+30
yaml/ocaml-yamle/tests/test_simple_key_debug.ml
···
+
open Yamle
+
+
let test_case name yaml =
+
Printf.printf "\n=== Testing %s ===\n" name;
+
Printf.printf "YAML:\n%s\n\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.next scanner with
+
| None -> Printf.printf "Done\n"
+
| Some tok ->
+
Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok);
+
print_tokens ()
+
in
+
try
+
print_tokens ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* Test A984 - Multiline Scalar in Mapping *)
+
test_case "A984" "a: b\n c\nd:\n e\n f";
+
+
(* Test RZP5 - Trailing Comments *)
+
test_case "RZP5" "- #lala\n seq2";
+
+
(* Simplified versions *)
+
test_case "Simple multiline" "a: b\n c";
+
test_case "Simple block entry with comment" "- # comment\n value";
+
test_case "After block scalar" "a: |\n text\nb: c"
+21
yaml/ocaml-yamle/tests/test_simple_single.ml
···
+
(* Simple test of single-quoted scalar *)
+
open Yamle
+
+
let () =
+
let yaml = "'foo\n\nbar'" in
+
Printf.printf "Input: %s\n" (String.escaped yaml);
+
+
let scanner = Scanner.of_string yaml in
+
Scanner.iter (fun tok ->
+
match tok.Token.token with
+
| Token.Scalar { value; style; _ } ->
+
Printf.printf "Scalar: %s (len=%d)\n" (String.escaped value) (String.length value);
+
Printf.printf "Style: %s\n" (match style with
+
| Scalar_style.Single_quoted -> "single"
+
| _ -> "other");
+
(* Print each character *)
+
for i = 0 to String.length value - 1 do
+
Printf.printf " [%d] = %C (code=%d)\n" i value.[i] (Char.code value.[i])
+
done
+
| _ -> ()
+
) scanner
+4
yaml/ocaml-yamle/tests/test_suite_lib/dune
···
+
(library
+
(name test_suite_lib)
+
(modules test_suite_loader tree_format)
+
(libraries yamle))
+176
yaml/ocaml-yamle/tests/test_suite_lib/test_suite_loader.ml
···
+
(* Load yaml-test-suite test cases from YAML format *)
+
open Yamle
+
+
type test_case = {
+
id : string;
+
name : string;
+
yaml : string;
+
tree : string option;
+
fail : bool;
+
}
+
+
let read_file path =
+
let ic = open_in path in
+
let n = in_channel_length ic in
+
let s = really_input_string ic n in
+
close_in ic;
+
s
+
+
(* Convert YAML test suite visual representations to actual characters *)
+
let convert_test_yaml yaml =
+
let result = Buffer.create (String.length yaml) in
+
let len = String.length yaml in
+
let rec process i =
+
if i >= len then ()
+
else
+
(* Check for multi-character sequences - must check longest first *)
+
(* ————» = em-dash em-dash em-dash em-dash guillemet (4 spaces = tab expanded) *)
+
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
+
Buffer.add_char result '\t';
+
process (i + 14)
+
end
+
(* ———» = em-dash em-dash em-dash guillemet *)
+
else if i + 11 <= len && String.sub yaml i 11 = "\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xc2\xbb" then begin
+
Buffer.add_char result '\t';
+
process (i + 11)
+
end
+
(* ——» = em-dash em-dash guillemet *)
+
else if i + 8 <= len && String.sub yaml i 8 = "\xe2\x80\x94\xe2\x80\x94\xc2\xbb" then begin
+
Buffer.add_char result '\t';
+
process (i + 8)
+
end
+
(* —» = em-dash guillemet *)
+
else if i + 5 <= len && String.sub yaml i 5 = "\xe2\x80\x94\xc2\xbb" then begin
+
Buffer.add_char result '\t';
+
process (i + 5)
+
end
+
(* » = guillemet alone *)
+
else if i + 2 <= len && String.sub yaml i 2 = "\xc2\xbb" then begin
+
Buffer.add_char result '\t';
+
process (i + 2)
+
end
+
(* ␣ = open box for trailing space *)
+
else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x90\xa3" then begin
+
Buffer.add_char result ' ';
+
process (i + 3)
+
end
+
(* ← = leftwards arrow for carriage return *)
+
else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x86\x90" then begin
+
Buffer.add_char result '\r';
+
process (i + 3)
+
end
+
(* ⇔ = left-right double arrow for BOM *)
+
else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x87\x94" then begin
+
Buffer.add_string result "\xEF\xBB\xBF";
+
process (i + 3)
+
end
+
(* ↵ = up-down arrow for explicit newline.
+
This represents a newline in the output AND replaces the following actual newline
+
(since each ↵ is on its own line in the test file's yaml field). *)
+
else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x86\xb5" then begin
+
Buffer.add_char result '\n';
+
(* Skip the following newline if present (it's part of the test file structure, not content) *)
+
let next_i = i + 3 in
+
if next_i < len && yaml.[next_i] = '\n' then
+
process (next_i + 1)
+
else
+
process next_i
+
end
+
(* ∎ = end-of-proof symbol for empty stream *)
+
else if i + 3 <= len && String.sub yaml i 3 = "\xe2\x88\x8e" then begin
+
(* Skip this - it represents an empty file, so we add nothing *)
+
process (i + 3)
+
end
+
else begin
+
Buffer.add_char result yaml.[i];
+
process (i + 1)
+
end
+
in
+
process 0;
+
Buffer.contents result
+
+
(* Extract a field value from parsed YAML events *)
+
let extract_mapping_value events key =
+
let rec find_key = function
+
| [] -> None
+
| { Event.event = Event.Scalar { value; _ }; _ } :: rest when value = key ->
+
(* Found the key, now get the value *)
+
(match rest with
+
| { Event.event = Event.Scalar { value; _ }; _ } :: _ -> Some value
+
| _ -> None)
+
| _ :: rest -> find_key rest
+
in
+
find_key events
+
+
(* Parse a single test case from a mapping *)
+
let parse_test_case id events =
+
let name = match extract_mapping_value events "name" with
+
| Some n -> n
+
| None -> id
+
in
+
let yaml = match extract_mapping_value events "yaml" with
+
| Some y -> convert_test_yaml y
+
| None -> ""
+
in
+
let tree = extract_mapping_value events "tree" in
+
let fail = match extract_mapping_value events "fail" with
+
| Some "true" -> true
+
| _ -> Option.is_some (extract_mapping_value events "error")
+
in
+
{ id; name; yaml; tree; fail }
+
+
(* Load tests from a single YAML file *)
+
let load_file path =
+
let id = Filename.chop_extension (Filename.basename path) in
+
try
+
let content = read_file path in
+
let parser = Parser.of_string content in
+
let events = Parser.to_list parser in
+
+
(* File contains a sequence of test cases *)
+
let tests = ref [] in
+
let current_events = ref [] in
+
let in_mapping = ref false in
+
let depth = ref 0 in
+
let test_index = ref 0 in
+
+
List.iter (fun (e : Event.spanned) ->
+
match e.event with
+
| Event.Mapping_start _ when !depth = 1 ->
+
in_mapping := true;
+
current_events := [e];
+
incr depth
+
| Event.Mapping_end when !depth = 2 ->
+
current_events := e :: !current_events;
+
let test_id = if !test_index = 0 then id else Printf.sprintf "%s/%02d" id !test_index in
+
let test = parse_test_case test_id (List.rev !current_events) in
+
if test.yaml <> "" then tests := test :: !tests;
+
in_mapping := false;
+
current_events := [];
+
incr test_index;
+
decr depth
+
| _ when !in_mapping ->
+
current_events := e :: !current_events;
+
(match e.event with
+
| Event.Mapping_start _ | Event.Sequence_start _ -> incr depth
+
| Event.Mapping_end | Event.Sequence_end -> decr depth
+
| _ -> ())
+
| Event.Sequence_start _ when !depth = 0 -> depth := 1
+
| Event.Sequence_end when !depth = 1 -> depth := 0
+
| _ -> ()
+
) events;
+
+
List.rev !tests
+
with _ -> []
+
+
let load_directory src_path =
+
let entries = Sys.readdir src_path in
+
let tests = ref [] in
+
Array.iter (fun entry ->
+
if Filename.check_suffix entry ".yaml" then begin
+
let path = Filename.concat src_path entry in
+
let file_tests = load_file path in
+
tests := file_tests @ !tests
+
end
+
) entries;
+
List.sort (fun a b -> String.compare a.id b.id) !tests
+91
yaml/ocaml-yamle/tests/test_suite_lib/tree_format.ml
···
+
(* Format parser events as tree notation compatible with yaml-test-suite *)
+
+
open Yamle
+
+
let escape_string s =
+
let buf = Buffer.create (String.length s * 2) in
+
let len = String.length s in
+
(* Find the last non-space character to identify trailing spaces *)
+
let rec find_last_non_space i =
+
if i < 0 then -1
+
else if s.[i] <> ' ' then i
+
else find_last_non_space (i - 1)
+
in
+
let last_non_space = find_last_non_space (len - 1) in
+
+
String.iteri (fun i c ->
+
match c with
+
| '\n' -> Buffer.add_string buf "\\n"
+
| '\t' -> Buffer.add_string buf "\\t"
+
| '\r' -> Buffer.add_string buf "\\r"
+
| '\\' -> Buffer.add_string buf "\\\\"
+
| '\x00' -> Buffer.add_string buf "\\0"
+
| '\x07' -> Buffer.add_string buf "\\a"
+
| '\x08' -> Buffer.add_string buf "\\b"
+
| '\x0b' -> Buffer.add_string buf "\\v"
+
| '\x0c' -> Buffer.add_string buf "\\f"
+
| '\x1b' -> Buffer.add_string buf "\\e"
+
| '\xa0' -> Buffer.add_string buf "\\_"
+
| ' ' when i > last_non_space ->
+
(* Trailing space - show with open box character *)
+
Buffer.add_string buf "\xe2\x90\xa3"
+
| c -> Buffer.add_char buf c
+
) s;
+
Buffer.contents buf
+
+
let style_char = function
+
| Scalar_style.Plain -> ':'
+
| Scalar_style.Single_quoted -> '\''
+
| Scalar_style.Double_quoted -> '"'
+
| Scalar_style.Literal -> '|'
+
| Scalar_style.Folded -> '>'
+
| Scalar_style.Any -> ':'
+
+
let format_event depth { Event.event; span = _span } =
+
let indent = String.make depth ' ' in
+
match event with
+
| Event.Stream_start _ -> "+STR"
+
| Event.Stream_end -> "-STR"
+
| Event.Document_start { implicit; _ } ->
+
if implicit then Printf.sprintf "%s+DOC" indent
+
else Printf.sprintf "%s+DOC ---" indent
+
| Event.Document_end { implicit } ->
+
if implicit then Printf.sprintf "%s-DOC" indent
+
else Printf.sprintf "%s-DOC ..." indent
+
| Event.Mapping_start { anchor; tag; style; _ } ->
+
let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
+
let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
+
let flow_str = match style with Layout_style.Flow -> " {}" | _ -> "" in
+
Printf.sprintf "%s+MAP%s%s%s" indent flow_str anchor_str tag_str
+
| Event.Mapping_end -> Printf.sprintf "%s-MAP" indent
+
| Event.Sequence_start { anchor; tag; style; _ } ->
+
let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
+
let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
+
let flow_str = match style with Layout_style.Flow -> " []" | _ -> "" in
+
Printf.sprintf "%s+SEQ%s%s%s" indent flow_str anchor_str tag_str
+
| Event.Sequence_end -> Printf.sprintf "%s-SEQ" indent
+
| Event.Scalar { anchor; tag; value; style; _ } ->
+
let anchor_str = match anchor with Some a -> " &" ^ a | None -> "" in
+
let tag_str = match tag with Some t -> " <" ^ t ^ ">" | None -> "" in
+
let style_c = style_char style in
+
Printf.sprintf "%s=VAL%s%s %c%s" indent anchor_str tag_str style_c (escape_string value)
+
| Event.Alias { anchor } ->
+
Printf.sprintf "%s=ALI *%s" indent anchor
+
+
let of_spanned_events events =
+
let buf = Buffer.create 256 in
+
let depth = ref 0 in
+
List.iter (fun (e : Event.spanned) ->
+
(match e.event with
+
| Event.Stream_end | Event.Document_end _ | Event.Mapping_end | Event.Sequence_end ->
+
decr depth
+
| _ -> ());
+
let line = format_event !depth e in
+
Buffer.add_string buf line;
+
Buffer.add_char buf '\n';
+
(match e.event with
+
| Event.Stream_start _ | Event.Document_start _ | Event.Mapping_start _ | Event.Sequence_start _ ->
+
incr depth
+
| _ -> ())
+
) events;
+
Buffer.contents buf
+21
yaml/ocaml-yamle/tests/test_sy6v.ml
···
+
open Yamle
+
+
let () =
+
let yaml = "&anchor - sequence entry\n" in
+
Printf.printf "YAML: %S\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "\nTokens:\n";
+
try
+
let rec loop () =
+
match Scanner.next scanner with
+
| None -> Printf.printf " (none)\n"
+
| Some tok ->
+
Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column
+
(Format.asprintf "%a" Token.pp tok.token);
+
match tok.token with
+
| Token.Stream_end -> ()
+
| _ -> loop ()
+
in
+
loop ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+24
yaml/ocaml-yamle/tests/test_tokens2.ml
···
+
open Yamle
+
+
let yaml = {|'implicit block key' : [
+
'implicit flow key' : value,
+
]|}
+
+
let () =
+
let scanner = Scanner.of_string yaml in
+
let rec print_all n =
+
match Scanner.next scanner with
+
| None -> ()
+
| Some tok ->
+
Printf.printf "%2d. " n;
+
(match tok.Token.token with
+
| Token.Flow_sequence_start -> Printf.printf "Flow_sequence_start"
+
| Token.Flow_sequence_end -> Printf.printf "Flow_sequence_end"
+
| Token.Flow_entry -> Printf.printf "Flow_entry"
+
| Token.Value -> Printf.printf "Value"
+
| Token.Scalar {value; _} -> Printf.printf "Scalar(%S)" value
+
| _ -> Printf.printf "Other");
+
Printf.printf " at %d:%d\n" tok.span.start.line tok.span.start.column;
+
print_all (n + 1)
+
in
+
print_all 0
+19
yaml/ocaml-yamle/tests/test_trace_a984.ml
···
+
open Yamle
+
+
let () =
+
(* Minimal A984 reproduction *)
+
let yaml = "d:\n e" in
+
Printf.printf "Testing minimal A984:\n%s\n\n" yaml;
+
let scanner = Scanner.of_string yaml in
+
Printf.printf "Tokens:\n";
+
let rec print_tokens () =
+
match Scanner.next scanner with
+
| None -> Printf.printf "Done\n"
+
| Some tok ->
+
Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok);
+
print_tokens ()
+
in
+
try
+
print_tokens ()
+
with e ->
+
Printf.printf "Error: %s\n" (Printexc.to_string e)
+41
yaml/ocaml-yamle/tests/test_y79y.ml
···
+
(* Debug Y79Y test cases *)
+
open Yamle
+
+
let () =
+
(* Test case 1: fail=true - tabs at wrong indentation in block scalar *)
+
let yaml1 = "foo: |\n \t\nbar: 1" in
+
Printf.printf "=== Test 1 (should fail) ===\n";
+
Printf.printf "Input: %S\n" yaml1;
+
Printf.printf "Visual:\n";
+
String.iter (fun c ->
+
if c = '\t' then Printf.printf "<TAB>"
+
else if c = '\n' then Printf.printf "<NL>\n"
+
else Printf.printf "%c" c
+
) yaml1;
+
Printf.printf "\n";
+
(try
+
let parser = Parser.of_string yaml1 in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events);
+
Printf.printf "ERROR: Should have failed but didn't!\n\n"
+
with e ->
+
Printf.printf "Failed as expected: %s\n\n" (Printexc.to_string e));
+
+
(* Test case 2: should succeed - tab with proper indentation in block scalar *)
+
let yaml2 = "foo: |\n \t\nbar: 1" in
+
Printf.printf "=== Test 2 (should succeed) ===\n";
+
Printf.printf "Input: %S\n" yaml2;
+
Printf.printf "Visual:\n";
+
String.iter (fun c ->
+
if c = '\t' then Printf.printf "<TAB>"
+
else if c = '\n' then Printf.printf "<NL>\n"
+
else Printf.printf "%c" c
+
) yaml2;
+
Printf.printf "\n";
+
(try
+
let parser = Parser.of_string yaml2 in
+
let events = Parser.to_list parser in
+
Printf.printf "Events: %d\n" (List.length events);
+
Printf.printf "\n"
+
with e ->
+
Printf.printf "ERROR: Failed but should succeed: %s\n\n" (Printexc.to_string e))
+68
yaml/ocaml-yamle/tests/test_y79y_all.ml
···
+
(* Test all Y79Y cases *)
+
+
let test_case name yaml should_fail =
+
Printf.printf "=== %s ===\n" name;
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let _tokens = Yamle.Scanner.to_list scanner in
+
if should_fail then begin
+
Printf.printf "FAIL: Expected error but parsing succeeded\n";
+
false
+
end else begin
+
Printf.printf "PASS: Parsing succeeded as expected\n";
+
true
+
end
+
with e ->
+
if should_fail then begin
+
Printf.printf "PASS: Failed as expected (%s)\n" (Printexc.to_string e);
+
true
+
end else begin
+
Printf.printf "FAIL: Unexpected error (%s)\n" (Printexc.to_string e);
+
false
+
end
+
+
let () =
+
let results = ref [] in
+
+
(* Y79Y/00: Tab at start - should FAIL *)
+
results := test_case "Y79Y/00" "foo: |\n\t\nbar: 1" true :: !results;
+
+
(* Y79Y/01: Tab after 1 space - should PASS *)
+
results := test_case "Y79Y/01" "foo: |\n \t\nbar: 1" false :: !results;
+
+
(* Y79Y/02: Tab in flow sequence after newline - should PASS *)
+
results := test_case "Y79Y/02" "- [\n\t\n foo\n ]" false :: !results;
+
+
(* Y79Y/03: Tab immediately after flow start and content - should FAIL *)
+
results := test_case "Y79Y/03" "- [\n\tfoo,\n foo\n ]" true :: !results;
+
+
(* Y79Y/04: Tab after dash at root level - should FAIL *)
+
results := test_case "Y79Y/04" "-\t-" true :: !results;
+
+
(* Y79Y/05: Tab after dash with space - should FAIL *)
+
results := test_case "Y79Y/05" "- \t-" true :: !results;
+
+
(* Y79Y/06: Tab after ? at root level - should FAIL *)
+
results := test_case "Y79Y/06" "?\t-" true :: !results;
+
+
(* Y79Y/07: Tab after : in explicit mapping - should FAIL *)
+
results := test_case "Y79Y/07" "? -\n:\t-" true :: !results;
+
+
(* Y79Y/08: Tab after ? before key - should FAIL *)
+
results := test_case "Y79Y/08" "?\tkey:" true :: !results;
+
+
(* Y79Y/09: Tab after : in explicit mapping - should FAIL *)
+
results := test_case "Y79Y/09" "? key:\n:\tkey:" true :: !results;
+
+
(* Y79Y/10: Tab before number (content) - should PASS *)
+
results := test_case "Y79Y/10" "-\t-1" false :: !results;
+
+
Printf.printf "\n=== Summary ===\n";
+
let passed = List.filter (fun x -> x) !results |> List.length in
+
let total = List.length !results in
+
Printf.printf "%d/%d tests passed\n" passed total;
+
if passed = total then
+
Printf.printf "All tests PASSED!\n"
+
else
+
Printf.printf "Some tests FAILED\n";
+
exit (if passed = total then 0 else 1)
+13
yaml/ocaml-yamle/tests/test_y79y_simple.ml
···
+
(* Simple Y79Y test *)
+
+
let () =
+
(* Test case 1: should fail - tab at wrong indentation *)
+
let yaml1 = "foo: |\n \t\nbar: 1" in
+
Printf.printf "=== Test 1 (should fail) ===\n";
+
Printf.printf "Testing: %S\n" yaml1;
+
(try
+
let scanner = Yamle.Scanner.of_string yaml1 in
+
let _tokens = Yamle.Scanner.to_list scanner in
+
Printf.printf "ERROR: Scanning succeeded but should have failed!\n"
+
with e ->
+
Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e))
+44
yaml/ocaml-yamle/tests/test_y79y_trace.ml
···
+
(* Trace Y79Y test *)
+
+
let test_case yaml desc should_fail expected_scalars =
+
Printf.printf "=== %s ===\n" desc;
+
Printf.printf "Testing: %S\n" yaml;
+
try
+
let scanner = Yamle.Scanner.of_string yaml in
+
let tokens = Yamle.Scanner.to_list scanner in
+
if should_fail then
+
Printf.printf "ERROR: Expected to fail but got %d tokens\n" (List.length tokens)
+
else begin
+
Printf.printf "OK: Got %d tokens\n" (List.length tokens);
+
let scalars = ref [] in
+
List.iter (fun (t : Yamle.Token.spanned) ->
+
match t.token with
+
| Yamle.Token.Scalar { value; _ } ->
+
scalars := value :: !scalars;
+
Printf.printf " Scalar: %S\n" value
+
| _ -> ()
+
) tokens;
+
let scalars = List.rev !scalars in
+
if scalars <> expected_scalars then begin
+
Printf.printf "ERROR: Expected scalars %s but got %s\n"
+
(String.concat ", " (List.map (Printf.sprintf "%S") expected_scalars))
+
(String.concat ", " (List.map (Printf.sprintf "%S") scalars))
+
end
+
end
+
with e ->
+
if should_fail then
+
Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e)
+
else
+
Printf.printf "ERROR: Unexpected failure: %s\n" (Printexc.to_string e)
+
+
let () =
+
(* Test case 0 (Y79Y): should fail - tab at start of content *)
+
let yaml0 = "foo: |\n\t\nbar: 1" in
+
test_case yaml0 "Y79Y/00: tab at start (no spaces)" true [];
+
Printf.printf "\n";
+
+
(* Test case 1 (Y79Y/01): should succeed - tab after 1 space indent *)
+
(* Expected: foo="\t\n", bar="1" *)
+
let yaml1 = "foo: |\n \t\nbar: 1" in
+
test_case yaml1 "Y79Y/01: tab after 1 space" false ["foo"; "\t\n"; "bar"; "1"];
+
Printf.printf "\n"