this repo has no description
0
fork

Configure Feed

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

more

+356 -2190
-93
yaml/ocaml-yamle/tests/categorize_failures.ml
··· 1 - (* Categorize test failures *) 2 - open Yamle 3 - module TL = Test_suite_lib.Test_suite_loader 4 - module TF = Test_suite_lib.Tree_format 5 - 6 - let test_suite_path = "../yaml-test-suite" 7 - 8 - let normalize_tree s = 9 - let lines = String.split_on_char '\n' s in 10 - let lines = List.filter (fun l -> String.trim l <> "") lines in 11 - String.concat "\n" lines 12 - 13 - type failure = 14 - | Error_not_detected of string 15 - | Parse_error of string 16 - | Tree_mismatch of string * string 17 - 18 - let run_test (test : TL.test_case) = 19 - if test.fail then begin 20 - try 21 - let parser = Parser.of_string test.yaml in 22 - let _events = Parser.to_list parser in 23 - Some (Error_not_detected test.name) 24 - with _ -> None 25 - end 26 - else begin 27 - match test.tree with 28 - | None -> None 29 - | Some expected -> 30 - try 31 - let parser = Parser.of_string test.yaml in 32 - let events = Parser.to_list parser in 33 - let actual = TF.of_spanned_events events in 34 - let expected_norm = normalize_tree expected in 35 - let actual_norm = normalize_tree actual in 36 - if expected_norm = actual_norm then None 37 - else Some (Tree_mismatch (expected_norm, actual_norm)) 38 - with e -> 39 - let msg = Printexc.to_string e in 40 - Some (Parse_error msg) 41 - end 42 - 43 - let diff_lines expected actual = 44 - let exp_lines = String.split_on_char '\n' expected in 45 - let act_lines = String.split_on_char '\n' actual in 46 - let rec find_diff i es as_ = 47 - match es, as_ with 48 - | [], [] -> None 49 - | [], _ -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines)) 50 - | _, [] -> Some (Printf.sprintf "Line count: expected %d, got %d" (List.length exp_lines) (List.length act_lines)) 51 - | e :: es', a :: as_' -> 52 - if e = a then find_diff (i + 1) es' as_' 53 - else Some (Printf.sprintf "Line %d differs:\n exp: %s\n got: %s" i e a) 54 - in 55 - find_diff 1 exp_lines act_lines 56 - 57 - let () = 58 - let src_path = Filename.concat test_suite_path "src" in 59 - let all_tests = TL.load_directory src_path in 60 - 61 - let error_not_detected = ref [] in 62 - let parse_errors = ref [] in 63 - let tree_mismatches = ref [] in 64 - 65 - List.iter (fun test -> 66 - match run_test test with 67 - | None -> () 68 - | Some (Error_not_detected name) -> 69 - error_not_detected := (test.TL.id, name) :: !error_not_detected 70 - | Some (Parse_error msg) -> 71 - parse_errors := (test.TL.id, test.TL.name, msg) :: !parse_errors 72 - | Some (Tree_mismatch (exp, act)) -> 73 - tree_mismatches := (test.TL.id, test.TL.name, exp, act) :: !tree_mismatches 74 - ) all_tests; 75 - 76 - Printf.printf "=== ERROR TESTS NOT DETECTED (%d) ===\n" (List.length !error_not_detected); 77 - List.iter (fun (id, name) -> 78 - Printf.printf " %s: %s\n" id name 79 - ) (List.rev !error_not_detected); 80 - 81 - Printf.printf "\n=== PARSE ERRORS (%d) ===\n" (List.length !parse_errors); 82 - List.iter (fun (id, name, msg) -> 83 - Printf.printf " %s: %s\n %s\n" id name msg 84 - ) (List.rev !parse_errors); 85 - 86 - Printf.printf "\n=== TREE MISMATCHES (%d) ===\n" (List.length !tree_mismatches); 87 - List.iter (fun (id, name, exp, act) -> 88 - let diff = diff_lines exp act in 89 - Printf.printf " %s: %s\n" id name; 90 - match diff with 91 - | Some d -> Printf.printf " %s\n" d 92 - | None -> () 93 - ) (List.rev !tree_mismatches)
-12
yaml/ocaml-yamle/tests/count_tests.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - 3 - let () = 4 - let tests = TL.load_directory "../yaml-test-suite/src" in 5 - let error_without_tree = List.filter (fun t -> t.TL.fail && t.TL.tree = None) tests in 6 - let non_error_without_tree = List.filter (fun t -> (not t.TL.fail) && t.TL.tree = None) tests in 7 - Printf.printf "Error tests without tree: %d\n" (List.length error_without_tree); 8 - Printf.printf "Non-error tests without tree (will be skipped): %d\n" (List.length non_error_without_tree); 9 - Printf.printf "\nError tests without tree:\n"; 10 - List.iter (fun t -> Printf.printf " %s\n" t.TL.id) error_without_tree; 11 - Printf.printf "\nNon-error tests without tree:\n"; 12 - List.iter (fun t -> Printf.printf " %s\n" t.TL.id) non_error_without_tree
-71
yaml/ocaml-yamle/tests/debug_5we3_6m2f.ml
··· 1 - open Yamle 2 - 3 - let show_token tok = 4 - Format.asprintf "%a" Token.pp_spanned tok 5 - 6 - let show_event evt = 7 - Format.asprintf "%a" Event.pp_spanned evt 8 - 9 - let test_5we3 () = 10 - Printf.printf "\n=== Test 5WE3: Explicit Block Mapping Entries ===\n"; 11 - let yaml = "? explicit key # Empty value\n? |\n block key\n: - one # Explicit compact\n - two # block value" in 12 - Printf.printf "Input:\n%s\n\n" yaml; 13 - try 14 - let scanner = Scanner.of_string yaml in 15 - Printf.printf "Tokens:\n"; 16 - let rec print_tokens () = 17 - match Scanner.peek scanner with 18 - | None -> Printf.printf "No more tokens\n" 19 - | Some tok -> 20 - Printf.printf " %s\n" (show_token tok); 21 - ignore (Scanner.next scanner); 22 - print_tokens () 23 - in 24 - print_tokens (); 25 - Printf.printf "\nParsing:\n"; 26 - let scanner = Scanner.of_string yaml in 27 - let parser = Parser.create scanner in 28 - let rec print_events () = 29 - match Parser.next parser with 30 - | None -> Printf.printf "No more events\n" 31 - | Some event -> 32 - Printf.printf " %s\n" (show_event event); 33 - print_events () 34 - in 35 - print_events () 36 - with e -> 37 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 38 - 39 - let test_6m2f () = 40 - Printf.printf "\n=== Test 6M2F: Aliases in Explicit Block Mapping ===\n"; 41 - let yaml = "? &a a\n: &b b\n: *a" in 42 - Printf.printf "Input:\n%s\n\n" yaml; 43 - try 44 - let scanner = Scanner.of_string yaml in 45 - Printf.printf "Tokens:\n"; 46 - let rec print_tokens () = 47 - match Scanner.peek scanner with 48 - | None -> Printf.printf "No more tokens\n" 49 - | Some tok -> 50 - Printf.printf " %s\n" (show_token tok); 51 - ignore (Scanner.next scanner); 52 - print_tokens () 53 - in 54 - print_tokens (); 55 - Printf.printf "\nParsing:\n"; 56 - let scanner = Scanner.of_string yaml in 57 - let parser = Parser.create scanner in 58 - let rec print_events () = 59 - match Parser.next parser with 60 - | None -> Printf.printf "No more events\n" 61 - | Some event -> 62 - Printf.printf " %s\n" (show_event event); 63 - print_events () 64 - in 65 - print_events () 66 - with e -> 67 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 68 - 69 - let () = 70 - test_5we3 (); 71 - test_6m2f ()
-62
yaml/ocaml-yamle/tests/debug_block_issues.ml
··· 1 - open Yamle 2 - open Test_suite_lib 3 - 4 - let test_case name yaml expected_tree = 5 - Printf.printf "\n=== Testing %s ===\n" name; 6 - Printf.printf "YAML:\n%s\n" yaml; 7 - Printf.printf "\nExpected tree:\n%s\n" expected_tree; 8 - 9 - try 10 - let input = Input.of_string yaml in 11 - let scanner = Scanner.create input in 12 - let parser = Parser.create scanner in 13 - 14 - (* Skip token output for now *) 15 - (); 16 - 17 - Printf.printf "\nParsing...\n"; 18 - let rec collect_events acc = 19 - match Parser.next parser with 20 - | None -> List.rev acc 21 - | Some evt -> collect_events (evt :: acc) 22 - in 23 - let events = collect_events [] in 24 - 25 - let tree = Tree_format.of_spanned_events events in 26 - Printf.printf "\nFormatted tree:\n%s\n" tree; 27 - 28 - if tree = expected_tree then 29 - Printf.printf "✓ PASS\n" 30 - else 31 - Printf.printf "✗ FAIL - Tree mismatch\n" 32 - with 33 - | Error.Yamle_error err -> 34 - Printf.printf "ERROR: %s\n" (Error.to_string err) 35 - | e -> 36 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 37 - 38 - let () = 39 - (* JEF9 - Extra newlines at end *) 40 - test_case "JEF9" 41 - "- |+\n\n" 42 - "+STR\n +DOC\n +SEQ\n =VAL |\\n\\n\n -SEQ\n -DOC\n-STR"; 43 - 44 - (* K858 - Empty scalar chomping - block scalar consuming too much *) 45 - test_case "K858" 46 - "strip: >-\n\nclip: >\n\nkeep: |+\n\n" 47 - "+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"; 48 - 49 - (* L24T - Trailing whitespace-only line *) 50 - test_case "L24T" 51 - "foo: |\n x\n \n" 52 - "+STR\n +DOC\n +MAP\n =VAL :foo\n =VAL |x\\n \\n\n -MAP\n -DOC\n-STR"; 53 - 54 - (* MJS9 - Folded block newline handling *) 55 - test_case "MJS9" 56 - ">\n foo \n \n \t bar\n\n baz\n" 57 - "+STR\n +DOC\n =VAL >foo \\n\\n\\t bar\\n\\nbaz\\n\n -DOC\n-STR"; 58 - 59 - (* R4YG - Tab handling in folded block - just the problematic 4th test *) 60 - test_case "R4YG-4" 61 - "- >\n \t\n detected\n" 62 - "+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
··· 1 - (* Debug block scalar behavior *) 2 - open Yamle 3 - 4 - let test_simple name yaml expected = 5 - Printf.printf "\n=== %s ===\n" name; 6 - Printf.printf "Input: %S\n" yaml; 7 - Printf.printf "Expected: %S\n" expected; 8 - try 9 - let parser = Parser.of_string yaml in 10 - let events = Parser.to_list parser in 11 - List.iter (fun ev -> 12 - match ev.Event.event with 13 - | Event.Scalar { value; style; _ } -> 14 - let style_str = match style with 15 - | Scalar_style.Literal -> "Literal" 16 - | Scalar_style.Folded -> "Folded" 17 - | _ -> "Other" 18 - in 19 - Printf.printf "Scalar (%s): %S (len=%d)\n" style_str value (String.length value); 20 - Printf.printf " Escaped: %s\n" (String.escaped value); 21 - if value = expected then 22 - Printf.printf " PASS\n" 23 - else 24 - Printf.printf " FAIL: Expected %S\n" expected 25 - | _ -> () 26 - ) events 27 - with e -> 28 - Printf.printf "ERROR: %s\n" (Printexc.to_string e); 29 - Printexc.print_backtrace stdout 30 - 31 - let () = 32 - (* JEF9 - Keep chomping with empty content *) 33 - test_simple "JEF9" "- |+\n\n\n" "\n\n"; 34 - 35 - (* K858 - Empty scalar chomping *) 36 - test_simple "K858-strip" "strip: >-\n\n" ""; 37 - test_simple "K858-clip" "clip: >\n\n" ""; 38 - test_simple "K858-keep" "keep: |+\n\n" "\n"; 39 - 40 - (* L24T - Trailing spaces *) 41 - test_simple "L24T" "foo: |\n x\n \n" "x\n \n"; 42 - 43 - (* MJS9 - Folded newlines *) 44 - test_simple "MJS9" ">\n foo \n \n\t bar\n\n baz\n" "foo \n\n\t bar\n\nbaz\n"; 45 - 46 - (* R4YG - Tab preservation *) 47 - test_simple "R4YG" "- >\n \t\n detected\n" "\t\ndetected\n"
-13
yaml/ocaml-yamle/tests/debug_dk95_01.ml
··· 1 - open Yamle 2 - let () = 3 - (* DK95/01: foo: "bar<nl><4 tabs>baz" - 4 tabs at column 1 puts us at column 5, but quote started at 6 *) 4 - let yaml = "foo: \"bar\n\t\t\t\tbaz\"" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 10 - List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events 11 - with 12 - | Yamle_error e -> 13 - Format.printf "Error (expected): %a@." Error.pp e
-71
yaml/ocaml-yamle/tests/debug_empty_key.ml
··· 1 - open Yamle 2 - 3 - let show_token tok = 4 - Format.asprintf "%a" Token.pp_spanned tok 5 - 6 - let show_event evt = 7 - Format.asprintf "%a" Event.pp_spanned evt 8 - 9 - let test_2jqs () = 10 - Printf.printf "\n=== Test 2JQS: Block Mapping with Missing Keys ===\n"; 11 - let yaml = ": a\n: b" in 12 - Printf.printf "Input:\n%s\n\n" yaml; 13 - try 14 - let scanner = Scanner.of_string yaml in 15 - Printf.printf "Tokens:\n"; 16 - let rec print_tokens () = 17 - match Scanner.peek scanner with 18 - | None -> Printf.printf "No more tokens\n" 19 - | Some tok -> 20 - Printf.printf " %s\n" (show_token tok); 21 - ignore (Scanner.next scanner); 22 - print_tokens () 23 - in 24 - print_tokens (); 25 - Printf.printf "\nParsing:\n"; 26 - let scanner = Scanner.of_string yaml in 27 - let parser = Parser.create scanner in 28 - let rec print_events () = 29 - match Parser.next parser with 30 - | None -> Printf.printf "No more events\n" 31 - | Some event -> 32 - Printf.printf " %s\n" (show_event event); 33 - print_events () 34 - in 35 - print_events () 36 - with e -> 37 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 38 - 39 - let test_5nyz () = 40 - Printf.printf "\n=== Test 5NYZ: Separated Comment ===\n"; 41 - let yaml = "key: # Comment\n value" in 42 - Printf.printf "Input:\n%s\n\n" yaml; 43 - try 44 - let scanner = Scanner.of_string yaml in 45 - Printf.printf "Tokens:\n"; 46 - let rec print_tokens () = 47 - match Scanner.peek scanner with 48 - | None -> Printf.printf "No more tokens\n" 49 - | Some tok -> 50 - Printf.printf " %s\n" (show_token tok); 51 - ignore (Scanner.next scanner); 52 - print_tokens () 53 - in 54 - print_tokens (); 55 - Printf.printf "\nParsing:\n"; 56 - let scanner = Scanner.of_string yaml in 57 - let parser = Parser.create scanner in 58 - let rec print_events () = 59 - match Parser.next parser with 60 - | None -> Printf.printf "No more events\n" 61 - | Some event -> 62 - Printf.printf " %s\n" (show_event event); 63 - print_events () 64 - in 65 - print_events () 66 - with e -> 67 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 68 - 69 - let () = 70 - test_2jqs (); 71 - test_5nyz ()
-73
yaml/ocaml-yamle/tests/debug_flow.ml
··· 1 - (* Debug flow context issues *) 2 - open Yamle 3 - 4 - let show_error_kind = function 5 - | Error.Unexpected_character c -> Printf.sprintf "Unexpected_character(%c)" c 6 - | Error.Unexpected_eof -> "Unexpected_eof" 7 - | Error.Invalid_escape_sequence s -> Printf.sprintf "Invalid_escape_sequence(%s)" s 8 - | Error.Invalid_unicode_escape s -> Printf.sprintf "Invalid_unicode_escape(%s)" s 9 - | Error.Invalid_hex_escape s -> Printf.sprintf "Invalid_hex_escape(%s)" s 10 - | Error.Invalid_tag s -> Printf.sprintf "Invalid_tag(%s)" s 11 - | Error.Invalid_anchor s -> Printf.sprintf "Invalid_anchor(%s)" s 12 - | Error.Invalid_alias s -> Printf.sprintf "Invalid_alias(%s)" s 13 - | Error.Invalid_comment -> "Invalid_comment" 14 - | Error.Unclosed_single_quote -> "Unclosed_single_quote" 15 - | Error.Unclosed_double_quote -> "Unclosed_double_quote" 16 - | Error.Unclosed_flow_sequence -> "Unclosed_flow_sequence" 17 - | Error.Unclosed_flow_mapping -> "Unclosed_flow_mapping" 18 - | Error.Invalid_indentation (exp, got) -> Printf.sprintf "Invalid_indentation(expected %d, got %d)" exp got 19 - | Error.Invalid_flow_indentation -> "Invalid_flow_indentation" 20 - | Error.Tab_in_indentation -> "Tab_in_indentation" 21 - | Error.Invalid_block_scalar_header s -> Printf.sprintf "Invalid_block_scalar_header(%s)" s 22 - | Error.Invalid_directive s -> Printf.sprintf "Invalid_directive(%s)" s 23 - | Error.Invalid_yaml_version s -> Printf.sprintf "Invalid_yaml_version(%s)" s 24 - | Error.Invalid_tag_directive s -> Printf.sprintf "Invalid_tag_directive(%s)" s 25 - | Error.Reserved_directive s -> Printf.sprintf "Reserved_directive(%s)" s 26 - | Error.Unexpected_token s -> Printf.sprintf "Unexpected_token(%s)" s 27 - | Error.Expected_document_start -> "Expected_document_start" 28 - | Error.Expected_document_end -> "Expected_document_end" 29 - | Error.Expected_block_entry -> "Expected_block_entry" 30 - | Error.Expected_key -> "Expected_key" 31 - | Error.Expected_value -> "Expected_value" 32 - | Error.Expected_node -> "Expected_node" 33 - | Error.Expected_scalar -> "Expected_scalar" 34 - | Error.Expected_sequence_end -> "Expected_sequence_end" 35 - | Error.Expected_mapping_end -> "Expected_mapping_end" 36 - | Error.Duplicate_anchor s -> Printf.sprintf "Duplicate_anchor(%s)" s 37 - | Error.Undefined_alias s -> Printf.sprintf "Undefined_alias(%s)" s 38 - | Error.Alias_cycle s -> Printf.sprintf "Alias_cycle(%s)" s 39 - | Error.Multiple_documents -> "Multiple_documents" 40 - | Error.Mapping_key_too_long -> "Mapping_key_too_long" 41 - | Error.Custom s -> Printf.sprintf "Custom(%s)" s 42 - | _ -> "Unknown error" 43 - 44 - let test_case id yaml = 45 - Printf.printf "\n=== Test %s ===\n%!" id; 46 - Printf.printf "YAML: %S\n%!" yaml; 47 - try 48 - let parser = Parser.of_string yaml in 49 - let events = Parser.to_list parser in 50 - Printf.printf "SUCCESS - got %d events\n%!" (List.length events) 51 - with Error.Yamle_error err -> 52 - let pos_str = match err.Error.span with 53 - | Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column 54 - | None -> "" 55 - in 56 - Printf.printf "ERROR%s: %s\n%!" pos_str (show_error_kind err.Error.kind) 57 - 58 - let () = 59 - (* Test 87E4: Single Quoted Implicit Keys *) 60 - test_case "87E4" {|'implicit block key' : [ 61 - 'implicit flow key' : value, 62 - ]|}; 63 - 64 - (* Test CFD4: Empty implicit key *) 65 - test_case "CFD4" {|- [ : empty key ]|}; 66 - 67 - (* Test L9U5: Plain Implicit Keys *) 68 - test_case "L9U5" {|implicit block key : [ 69 - implicit flow key : value, 70 - ]|}; 71 - 72 - (* Test 9MMW: Single Pair Implicit Entries *) 73 - test_case "9MMW" {|- [ YAML : separate ]|};
-61
yaml/ocaml-yamle/tests/debug_flow2.ml
··· 1 - (* Debug tokenization *) 2 - open Yamle 3 - 4 - let show_token = function 5 - | Token.Stream_start enc -> Printf.sprintf "Stream_start(%s)" (match enc with Utf8 -> "UTF8" | _ -> "?") 6 - | Token.Stream_end -> "Stream_end" 7 - | Token.Document_start -> "Document_start" 8 - | Token.Document_end -> "Document_end" 9 - | Token.Block_mapping_start -> "Block_mapping_start" 10 - | Token.Block_sequence_start -> "Block_sequence_start" 11 - | Token.Block_end -> "Block_end" 12 - | Token.Flow_sequence_start -> "Flow_sequence_start" 13 - | Token.Flow_sequence_end -> "Flow_sequence_end" 14 - | Token.Flow_mapping_start -> "Flow_mapping_start" 15 - | Token.Flow_mapping_end -> "Flow_mapping_end" 16 - | Token.Block_entry -> "Block_entry" 17 - | Token.Flow_entry -> "Flow_entry" 18 - | Token.Key -> "Key" 19 - | Token.Value -> "Value" 20 - | Token.Alias s -> Printf.sprintf "Alias(%s)" s 21 - | Token.Anchor s -> Printf.sprintf "Anchor(%s)" s 22 - | Token.Tag {handle; suffix} -> Printf.sprintf "Tag(%s, %s)" handle suffix 23 - | Token.Scalar {value; style; _} -> 24 - let style_str = match style with 25 - | Plain -> "Plain" | Single_quoted -> "Single" | Double_quoted -> "Double" 26 - | Literal -> "Literal" | Folded -> "Folded" | _ -> "Other" 27 - in 28 - Printf.sprintf "Scalar(%S, %s)" value style_str 29 - | _ -> "Other" 30 - 31 - let test_case id yaml = 32 - Printf.printf "\n=== Test %s ===\n%!" id; 33 - Printf.printf "YAML: %S\n%!" yaml; 34 - Printf.printf "Tokens:\n%!"; 35 - try 36 - let scanner = Scanner.of_string yaml in 37 - let rec print_tokens () = 38 - match Scanner.next scanner with 39 - | Some tok -> 40 - Printf.printf " %s at line %d col %d\n%!" 41 - (show_token tok.token) 42 - tok.span.start.line 43 - tok.span.start.column; 44 - print_tokens () 45 - | None -> () 46 - in 47 - print_tokens (); 48 - Printf.printf "SUCCESS\n%!" 49 - with Error.Yamle_error err -> 50 - let pos_str = match err.Error.span with 51 - | Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column 52 - | None -> "" 53 - in 54 - Printf.printf "ERROR%s\n%!" pos_str 55 - 56 - let () = 57 - (* Test CFD4: Empty implicit key *) 58 - test_case "CFD4" {|- [ : empty key ]|}; 59 - 60 - (* Test 9MMW: Single Pair Implicit Entries *) 61 - test_case "9MMW" {|- [ YAML : separate ]|};
-27
yaml/ocaml-yamle/tests/debug_flow3.ml
··· 1 - open Yamle 2 - 3 - let show_error_kind = function 4 - | Error.Expected_sequence_end -> "Expected_sequence_end" 5 - | Error.Expected_mapping_end -> "Expected_mapping_end" 6 - | Error.Unexpected_token s -> Printf.sprintf "Unexpected_token(%s)" s 7 - | Error.Expected_key -> "Expected_key" 8 - | Error.Expected_value -> "Expected_value" 9 - | Error.Expected_node -> "Expected_node" 10 - | _ -> "Other" 11 - 12 - let test yaml = 13 - Printf.printf "YAML: %S\n%!" yaml; 14 - try 15 - let parser = Parser.of_string yaml in 16 - let events = Parser.to_list parser in 17 - Printf.printf "SUCCESS - %d events\n%!" (List.length events) 18 - with Error.Yamle_error err -> 19 - let pos_str = match err.Error.span with 20 - | Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column 21 - | None -> "" 22 - in 23 - Printf.printf "ERROR%s: %s\n%!" pos_str (show_error_kind err.Error.kind) 24 - 25 - let () = 26 - test {|- [ : empty key ]|}; 27 - test {|- [ YAML : separate ]|};
-36
yaml/ocaml-yamle/tests/debug_flow4.ml
··· 1 - open Yamle 2 - 3 - let test yaml = 4 - Printf.printf "\n=== YAML: %S ===\n%!" yaml; 5 - try 6 - let parser = Parser.of_string yaml in 7 - let rec print_events n = 8 - match Parser.next parser with 9 - | None -> Printf.printf "Total events: %d\n%!" n 10 - | Some ev -> 11 - Printf.printf "Event %d: " n; 12 - (match ev.Event.event with 13 - | Event.Stream_start _ -> Printf.printf "Stream_start\n" 14 - | Event.Stream_end -> Printf.printf "Stream_end\n" 15 - | Event.Document_start _ -> Printf.printf "Document_start\n" 16 - | Event.Document_end _ -> Printf.printf "Document_end\n" 17 - | Event.Sequence_start _ -> Printf.printf "Sequence_start\n" 18 - | Event.Sequence_end -> Printf.printf "Sequence_end\n" 19 - | Event.Mapping_start _ -> Printf.printf "Mapping_start\n" 20 - | Event.Mapping_end -> Printf.printf "Mapping_end\n" 21 - | Event.Scalar {value; _} -> Printf.printf "Scalar(%S)\n" value 22 - | Event.Alias {anchor} -> Printf.printf "Alias(%s)\n" anchor); 23 - print_events (n + 1) 24 - in 25 - print_events 0; 26 - Printf.printf "SUCCESS\n%!" 27 - with Error.Yamle_error err -> 28 - let pos_str = match err.Error.span with 29 - | Some span -> Printf.sprintf " at line %d col %d" span.Span.start.Position.line span.Span.start.Position.column 30 - | None -> "" 31 - in 32 - Printf.printf "ERROR%s\n%!" pos_str 33 - 34 - let () = 35 - test {|- [ : empty key ]|}; 36 - test {|- [ YAML : separate ]|};
-29
yaml/ocaml-yamle/tests/debug_flow5.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - Printf.printf "Test: - [ : empty key ]\n%!"; 5 - try 6 - let scanner = Scanner.of_string {|- [ : empty key ]|} in 7 - Printf.printf "Tokens:\n%!"; 8 - let rec print_all n = 9 - match Scanner.next scanner with 10 - | None -> () 11 - | Some tok -> 12 - Printf.printf " %d. " n; 13 - (match tok.Token.token with 14 - | Token.Stream_start _ -> Printf.printf "Stream_start" 15 - | Token.Stream_end -> Printf.printf "Stream_end" 16 - | Token.Block_sequence_start -> Printf.printf "Block_sequence_start" 17 - | Token.Block_entry -> Printf.printf "Block_entry" 18 - | Token.Block_end -> Printf.printf "Block_end" 19 - | Token.Flow_sequence_start -> Printf.printf "Flow_sequence_start" 20 - | Token.Flow_sequence_end -> Printf.printf "Flow_sequence_end" 21 - | Token.Value -> Printf.printf "Value" 22 - | Token.Scalar {value; _} -> Printf.printf "Scalar(%S)" value 23 - | _ -> Printf.printf "Other"); 24 - Printf.printf " at %d:%d\n%!" tok.span.start.line tok.span.start.column; 25 - print_all (n + 1) 26 - in 27 - print_all 0 28 - with Error.Yamle_error _ -> 29 - Printf.printf "Scanner error\n%!"
-19
yaml/ocaml-yamle/tests/debug_flow6.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - Printf.printf "Test: - [ a ]\n%!"; 5 - let parser = Parser.of_string {|- [ a ]|} in 6 - let rec print_events n = 7 - match Parser.next parser with 8 - | None -> () 9 - | Some ev -> 10 - Printf.printf "%d: " n; 11 - (match ev.Event.event with 12 - | Event.Sequence_start _ -> Printf.printf "Sequence_start" 13 - | Event.Sequence_end -> Printf.printf "Sequence_end" 14 - | Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value 15 - | _ -> Printf.printf "Other"); 16 - Printf.printf "\n%!"; 17 - print_events (n + 1) 18 - in 19 - print_events 0
-30
yaml/ocaml-yamle/tests/debug_flow7.ml
··· 1 - open Yamle 2 - 3 - let test yaml = 4 - Printf.printf "\nYAML: %S\n%!" yaml; 5 - try 6 - let parser = Parser.of_string yaml in 7 - let rec print_events n = 8 - match Parser.next parser with 9 - | None -> Printf.printf "Total: %d events\n" n 10 - | Some ev -> 11 - Printf.printf "%d: " n; 12 - (match ev.Event.event with 13 - | Event.Sequence_start _ -> Printf.printf "Sequence_start" 14 - | Event.Sequence_end -> Printf.printf "Sequence_end" 15 - | Event.Mapping_start _ -> Printf.printf "Mapping_start" 16 - | Event.Mapping_end -> Printf.printf "Mapping_end" 17 - | Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value 18 - | _ -> Printf.printf "Other"); 19 - Printf.printf "\n%!"; 20 - print_events (n + 1) 21 - in 22 - print_events 0; 23 - Printf.printf "SUCCESS\n%!" 24 - with Error.Yamle_error _ -> 25 - Printf.printf "ERROR\n%!" 26 - 27 - let () = 28 - test {|[a, b]|}; (* Simple flow sequence *) 29 - test {|[{a: b}]|}; (* Flow sequence with mapping *) 30 - test {|[a: b]|}; (* Flow sequence with implicit mapping *)
-23
yaml/ocaml-yamle/tests/debug_from.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "---\n- name: Spec Example 2.4. Sequence of Mappings\n from: http://example.com\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - Printf.printf "\nTokens:\n"; 8 - try 9 - let rec loop count = 10 - if count > 30 then Printf.printf " ... (stopped at 30 tokens)\n" 11 - else match Scanner.next scanner with 12 - | None -> Printf.printf " (none)\n" 13 - | Some tok -> 14 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 15 - (Format.asprintf "%a" Token.pp tok.token); 16 - match tok.token with 17 - | Token.Stream_end -> () 18 - | _ -> loop (count + 1) 19 - in 20 - loop 0 21 - with e -> 22 - Printf.printf "Error: %s\n" (Printexc.to_string e); 23 - Printexc.print_backtrace stdout
-22
yaml/ocaml-yamle/tests/debug_jef9.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - module TF = Test_suite_lib.Tree_format 3 - open Yamle 4 - 5 - let () = 6 - let tests = TL.load_file "../yaml-test-suite/src/JEF9.yaml" in 7 - List.iter (fun (test : TL.test_case) -> 8 - Printf.printf "=== Test: %s ===\n" test.id; 9 - Printf.printf "YAML bytes: "; 10 - String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml; 11 - Printf.printf "\n"; 12 - Printf.printf "YAML len: %d\n" (String.length test.yaml); 13 - try 14 - let parser = Parser.of_string test.yaml in 15 - let events = Parser.to_list parser in 16 - Printf.printf "Events: %d\n" (List.length events); 17 - let tree = TF.of_spanned_events events in 18 - Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree); 19 - Printf.printf "Actual tree:\n%s\n" tree 20 - with e -> 21 - Printf.printf "Error: %s\n" (Printexc.to_string e) 22 - ) tests
-23
yaml/ocaml-yamle/tests/debug_l24t.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - module TF = Test_suite_lib.Tree_format 3 - open Yamle 4 - 5 - let () = 6 - let tests = TL.load_file "../yaml-test-suite/src/L24T.yaml" in 7 - List.iter (fun (test : TL.test_case) -> 8 - Printf.printf "=== Test: %s ===\n" test.id; 9 - Printf.printf "YAML bytes: "; 10 - String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml; 11 - Printf.printf "\n"; 12 - Printf.printf "YAML repr: %S\n" test.yaml; 13 - Printf.printf "YAML len: %d\n" (String.length test.yaml); 14 - try 15 - let parser = Parser.of_string test.yaml in 16 - let events = Parser.to_list parser in 17 - Printf.printf "Events: %d\n" (List.length events); 18 - let tree = TF.of_spanned_events events in 19 - Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree); 20 - Printf.printf "Actual tree:\n%s\n" tree 21 - with e -> 22 - Printf.printf "Error: %s\n" (Printexc.to_string e) 23 - ) tests
-28
yaml/ocaml-yamle/tests/debug_m2n8.ml
··· 1 - open Yamle 2 - module TF = Test_suite_lib.Tree_format 3 - 4 - let () = 5 - let yaml = "- ? : x\n" in 6 - Printf.printf "YAML: %S\n" yaml; 7 - Printf.printf "\nExpected tree:\n"; 8 - Printf.printf "+STR 9 - +DOC 10 - +SEQ 11 - +MAP 12 - +MAP 13 - =VAL : 14 - =VAL :x 15 - -MAP 16 - =VAL : 17 - -MAP 18 - -SEQ 19 - -DOC 20 - -STR\n"; 21 - Printf.printf "\nParsing:\n"; 22 - try 23 - let parser = Parser.of_string yaml in 24 - let events = Parser.to_list parser in 25 - let tree = TF.of_spanned_events events in 26 - Printf.printf "Actual tree:\n%s\n" tree 27 - with e -> 28 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-83
yaml/ocaml-yamle/tests/debug_multiline.ml
··· 1 - (* Debug specific multiline tests *) 2 - open Yamle 3 - 4 - let show_event evt = 5 - Format.asprintf "%a" Event.pp_spanned evt 6 - 7 - let test_a984 () = 8 - let yaml = "a: b\n c\nd:\n e\n f" in 9 - Printf.printf "Testing A984 (Multiline Scalar in Mapping):\n%s\n" yaml; 10 - try 11 - let scanner = Scanner.of_string yaml in 12 - let parser = Parser.create scanner in 13 - Printf.printf "Events:\n"; 14 - let rec print_events () = 15 - match Parser.next parser with 16 - | None -> () 17 - | Some event -> 18 - Printf.printf " %s\n" (show_event event); 19 - print_events () 20 - in 21 - print_events () 22 - with e -> 23 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 24 - 25 - let test_v9d5 () = 26 - let yaml = "- sun: yellow\n- ? earth: blue\n : moon: white" in 27 - Printf.printf "\nTesting V9D5 (Compact Block Mappings):\n%s\n" yaml; 28 - try 29 - let scanner = Scanner.of_string yaml in 30 - let parser = Parser.create scanner in 31 - Printf.printf "Events:\n"; 32 - let rec print_events () = 33 - match Parser.next parser with 34 - | None -> () 35 - | Some event -> 36 - Printf.printf " %s\n" (show_event event); 37 - print_events () 38 - in 39 - print_events () 40 - with e -> 41 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 42 - 43 - let test_q9wf () = 44 - let yaml = "{ first: Sammy, last: Sosa }:\n# Statistics:\n hr: # Home runs\n 65\n avg: # Average\n 0.278" in 45 - Printf.printf "\nTesting Q9WF (Separation Spaces):\n%s\n" yaml; 46 - try 47 - let scanner = Scanner.of_string yaml in 48 - let parser = Parser.create scanner in 49 - Printf.printf "Events:\n"; 50 - let rec print_events () = 51 - match Parser.next parser with 52 - | None -> () 53 - | Some event -> 54 - Printf.printf " %s\n" (show_event event); 55 - print_events () 56 - in 57 - print_events () 58 - with e -> 59 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 60 - 61 - let test_m2n8 () = 62 - let yaml = "- ? : x" in 63 - Printf.printf "\nTesting M2N8 (Question mark edge cases):\n%s\n" yaml; 64 - try 65 - let scanner = Scanner.of_string yaml in 66 - let parser = Parser.create scanner in 67 - Printf.printf "Events:\n"; 68 - let rec print_events () = 69 - match Parser.next parser with 70 - | None -> () 71 - | Some event -> 72 - Printf.printf " %s\n" (show_event event); 73 - print_events () 74 - in 75 - print_events () 76 - with e -> 77 - Printf.printf "ERROR: %s\n" (Printexc.to_string e) 78 - 79 - let () = 80 - test_a984 (); 81 - test_v9d5 (); 82 - test_q9wf (); 83 - test_m2n8 ()
-12
yaml/ocaml-yamle/tests/debug_mus6_01.ml
··· 1 - open Yamle 2 - let () = 3 - let yaml = "%YAML 1.2\n---\n%YAML 1.2\n---\n" in 4 - Format.printf "YAML: %S@.@." yaml; 5 - try 6 - let parser = Parser.of_string yaml in 7 - let events = Parser.to_list parser in 8 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 9 - List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events 10 - with 11 - | Yamle_error e -> 12 - Format.printf "Error (expected): %a@." Error.pp e
-7
yaml/ocaml-yamle/tests/debug_mus6_load.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - 3 - let () = 4 - let tests = TL.load_file "../yaml-test-suite/src/MUS6.yaml" in 5 - List.iter (fun t -> 6 - Printf.printf "ID: %s, fail: %b, yaml: %S\n" t.TL.id t.TL.fail t.TL.yaml 7 - ) tests
-41
yaml/ocaml-yamle/tests/debug_prh3.ml
··· 1 - (* Debug PRH3 specifically *) 2 - open Yamle 3 - 4 - let yaml = "' 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty '" 5 - 6 - let () = 7 - Printf.printf "Input YAML:\n"; 8 - for i = 0 to String.length yaml - 1 do 9 - let c = yaml.[i] in 10 - match c with 11 - | '\n' -> Printf.printf "\\n" 12 - | '\t' -> Printf.printf "\\t" 13 - | ' ' -> Printf.printf "·" 14 - | _ -> Printf.printf "%c" c 15 - done; 16 - Printf.printf "\n\n"; 17 - 18 - Printf.printf "Expected: ' 1st non-empty\\n2nd non-empty 3rd non-empty '\n"; 19 - Printf.printf "Expected (visual): '·1st·non-empty\\n2nd·non-empty·3rd·non-empty·'\n\n"; 20 - 21 - try 22 - let parser = Parser.of_string yaml in 23 - let events = Parser.to_list parser in 24 - List.iter (fun (e : Event.spanned) -> 25 - match e.event with 26 - | Event.Scalar { value; _ } -> 27 - Printf.printf "Actual scalar value:\n"; 28 - for i = 0 to String.length value - 1 do 29 - let c = value.[i] in 30 - match c with 31 - | '\n' -> Printf.printf "\\n" 32 - | '\t' -> Printf.printf "\\t" 33 - | ' ' -> Printf.printf "·" 34 - | _ -> Printf.printf "%c" c 35 - done; 36 - Printf.printf "\n"; 37 - Printf.printf "Length: %d\n" (String.length value) 38 - | _ -> () 39 - ) events 40 - with e -> 41 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-42
yaml/ocaml-yamle/tests/debug_quoted.ml
··· 1 - (* Debug quoted string issues *) 2 - open Yamle 3 - module TL = Test_suite_lib.Test_suite_loader 4 - module TF = Test_suite_lib.Tree_format 5 - 6 - let test_suite_path = "../yaml-test-suite" 7 - 8 - let () = 9 - let src_path = Filename.concat test_suite_path "src" in 10 - let all_tests = TL.load_directory src_path in 11 - 12 - (* Filter for specific tests *) 13 - let tests = List.filter (fun t -> 14 - t.TL.id = "PRH3" || t.TL.id = "T4YY" || t.TL.id = "NAT4" 15 - ) all_tests in 16 - 17 - List.iter (fun test -> 18 - Printf.printf "\n=== %s: %s ===\n" test.TL.id test.TL.name; 19 - Printf.printf "YAML input:\n%s\n" (String.escaped test.TL.yaml); 20 - Printf.printf "YAML (raw):\n%s\n---\n" test.TL.yaml; 21 - 22 - match test.TL.tree with 23 - | None -> Printf.printf "No expected tree\n" 24 - | Some expected -> 25 - Printf.printf "Expected tree:\n%s\n" expected; 26 - 27 - (try 28 - let parser = Parser.of_string test.TL.yaml in 29 - let events = Parser.to_list parser in 30 - let actual = TF.of_spanned_events events in 31 - Printf.printf "Actual tree:\n%s\n" actual; 32 - 33 - (* Show scalar values *) 34 - List.iter (fun (e : Event.spanned) -> 35 - match e.event with 36 - | Event.Scalar { value; _ } -> 37 - Printf.printf "Scalar value: %s (len=%d)\n" (String.escaped value) (String.length value) 38 - | _ -> () 39 - ) events; 40 - with e -> 41 - Printf.printf "Error: %s\n" (Printexc.to_string e)) 42 - ) tests
-23
yaml/ocaml-yamle/tests/debug_r4yg.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - module TF = Test_suite_lib.Tree_format 3 - open Yamle 4 - 5 - let () = 6 - let tests = TL.load_file "../yaml-test-suite/src/R4YG.yaml" in 7 - List.iter (fun (test : TL.test_case) -> 8 - Printf.printf "=== Test: %s ===\n" test.id; 9 - Printf.printf "YAML bytes: "; 10 - String.iter (fun c -> Printf.printf "%02x " (Char.code c)) test.yaml; 11 - Printf.printf "\n"; 12 - Printf.printf "YAML repr: %S\n" test.yaml; 13 - Printf.printf "YAML len: %d\n" (String.length test.yaml); 14 - try 15 - let parser = Parser.of_string test.yaml in 16 - let events = Parser.to_list parser in 17 - Printf.printf "Events: %d\n" (List.length events); 18 - let tree = TF.of_spanned_events events in 19 - Printf.printf "Expected tree:\n%s\n" (Option.value ~default:"(none)" test.tree); 20 - Printf.printf "Actual tree:\n%s\n" tree 21 - with e -> 22 - Printf.printf "Error: %s\n" (Printexc.to_string e) 23 - ) tests
-39
yaml/ocaml-yamle/tests/debug_v9d5.ml
··· 1 - open Yamle 2 - module TL = Test_suite_lib.Test_suite_loader 3 - module TF = Test_suite_lib.Tree_format 4 - 5 - let () = 6 - let tests = TL.load_file "../yaml-test-suite/src/V9D5.yaml" in 7 - List.iter (fun (test : TL.test_case) -> 8 - Printf.printf "=== Test: %s ===\n" test.id; 9 - Printf.printf "YAML: %S\n" test.yaml; 10 - 11 - (* Print tokens *) 12 - Printf.printf "\nTokens:\n"; 13 - let scanner = Scanner.of_string test.yaml in 14 - begin try 15 - let rec loop () = 16 - match Scanner.next scanner with 17 - | None -> Printf.printf " (none)\n" 18 - | Some tok -> 19 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 20 - (Format.asprintf "%a" Token.pp tok.token); 21 - match tok.token with 22 - | Token.Stream_end -> () 23 - | _ -> loop () 24 - in 25 - loop () 26 - with e -> 27 - Printf.printf "Scanner error: %s\n" (Printexc.to_string e) 28 - end; 29 - 30 - Printf.printf "\nExpected tree:\n%s\n" (Option.value ~default:"(none)" test.tree); 31 - Printf.printf "\nParsing:\n"; 32 - try 33 - let parser = Parser.of_string test.yaml in 34 - let events = Parser.to_list parser in 35 - let tree = TF.of_spanned_events events in 36 - Printf.printf "Actual tree:\n%s\n" tree 37 - with e -> 38 - Printf.printf "Error: %s\n" (Printexc.to_string e) 39 - ) tests
-13
yaml/ocaml-yamle/tests/debug_y79y_03.ml
··· 1 - open Yamle 2 - let () = 3 - (* Y79Y/03: - [<nl><tab>foo,<nl> foo<nl> ] *) 4 - let yaml = "- [\n\tfoo,\n foo\n ]" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 10 - List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events 11 - with 12 - | Yamle_error e -> 13 - Format.printf "Error (expected): %a@." Error.pp e
-13
yaml/ocaml-yamle/tests/debug_y79y_09.ml
··· 1 - open Yamle 2 - let () = 3 - (* Y79Y/09: ? key:<nl>:<tab>key: *) 4 - let yaml = "? key:\n:\tkey:" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 10 - List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events 11 - with 12 - | Yamle_error e -> 13 - Format.printf "Error (expected): %a@." Error.pp e
-13
yaml/ocaml-yamle/tests/debug_y79y_first.ml
··· 1 - open Yamle 2 - let () = 3 - (* Y79Y first test: block scalar followed by tab-only line *) 4 - let yaml = "foo: |\n\t\nbar: 1\n" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 10 - List.iter (fun e -> Format.printf " %a@." Event.pp_spanned e) events 11 - with 12 - | Yamle_error e -> 13 - Format.printf "Error (expected): %a@." Error.pp e
-186
yaml/ocaml-yamle/tests/dune
··· 7 7 (name run_all_tests) 8 8 (modules run_all_tests) 9 9 (libraries yamle test_suite_lib)) 10 - 11 - (executable 12 - (name categorize_failures) 13 - (modules categorize_failures) 14 - (libraries yamle test_suite_lib)) 15 - 16 - (executable 17 - (name debug_empty_key) 18 - (modules debug_empty_key) 19 - (libraries yamle)) 20 - 21 - (executable 22 - (name debug_5we3_6m2f) 23 - (modules debug_5we3_6m2f) 24 - (libraries yamle)) 25 - 26 - (executable 27 - (name test_6vjk_only) 28 - (modules test_6vjk_only) 29 - (libraries yamle)) 30 - 31 - (executable 32 - (name test_565n_debug) 33 - (modules test_565n_debug) 34 - (libraries yamle)) 35 - 36 - (executable 37 - (name debug_flow) 38 - (modules debug_flow) 39 - (libraries yamle)) 40 - 41 - (executable 42 - (name debug_flow2) 43 - (modules debug_flow2) 44 - (libraries yamle)) 45 - 46 - (executable 47 - (name debug_flow3) 48 - (modules debug_flow3) 49 - (libraries yamle)) 50 - 51 - (executable 52 - (name debug_flow4) 53 - (modules debug_flow4) 54 - (libraries yamle)) 55 - 56 - (executable 57 - (name debug_flow5) 58 - (modules debug_flow5) 59 - (libraries yamle)) 60 - 61 - (executable 62 - (name debug_flow6) 63 - (modules debug_flow6) 64 - (libraries yamle)) 65 - 66 - (executable 67 - (name debug_flow7) 68 - (modules debug_flow7) 69 - (libraries yamle)) 70 - 71 - (executable 72 - (name test_87e4) 73 - (modules test_87e4) 74 - (libraries yamle)) 75 - 76 - (executable 77 - (name test_tokens2) 78 - (modules test_tokens2) 79 - (libraries yamle)) 80 - 81 - (executable 82 - (name test_remaining) 83 - (modules test_remaining) 84 - (libraries yamle)) 85 - 86 - (executable 87 - (name debug_multiline) 88 - (modules debug_multiline) 89 - (libraries yamle)) 90 - 91 - (executable 92 - (name test_anchor_tag_issues) 93 - (modules test_anchor_tag_issues) 94 - (libraries yamle)) 95 - 96 - (executable 97 - (name debug_quoted) 98 - (modules debug_quoted) 99 - (libraries yamle test_suite_lib)) 100 - 101 - (executable 102 - (name debug_prh3) 103 - (modules debug_prh3) 104 - (libraries yamle)) 105 - 106 - (executable 107 - (name test_nat4_a) 108 - (modules test_nat4_a) 109 - (libraries yamle)) 110 - 111 - (executable 112 - (name test_simple_single) 113 - (modules test_simple_single) 114 - (libraries yamle)) 115 - 116 - (executable 117 - (name test_a984_trace) 118 - (modules test_a984_trace) 119 - (libraries yamle)) 120 - 121 - (executable 122 - (name debug_block_scalars) 123 - (modules debug_block_scalars) 124 - (libraries yamle)) 125 - 126 - (executable 127 - (name debug_jef9) 128 - (modules debug_jef9) 129 - (libraries yamle test_suite_lib)) 130 - 131 - (executable 132 - (name debug_l24t) 133 - (modules debug_l24t) 134 - (libraries yamle test_suite_lib)) 135 - 136 - (executable 137 - (name debug_r4yg) 138 - (modules debug_r4yg) 139 - (libraries yamle test_suite_lib)) 140 - 141 - (executable 142 - (name test_y79y) 143 - (modules test_y79y) 144 - (libraries yamle)) 145 - 146 - (executable 147 - (name test_y79y_simple) 148 - (modules test_y79y_simple) 149 - (libraries yamle)) 150 - 151 - (executable 152 - (name test_y79y_trace) 153 - (modules test_y79y_trace) 154 - (libraries yamle)) 155 - 156 - (executable 157 - (name test_y79y_all) 158 - (modules test_y79y_all) 159 - (libraries yamle)) 160 - 161 - (executable 162 - (name debug_block_issues) 163 - (modules debug_block_issues) 164 - (libraries yamle test_suite_lib)) 165 - (executable (name test_simple_key_debug) (modules test_simple_key_debug) (libraries yamle)) 166 - (executable (name test_trace_a984) (modules test_trace_a984) (libraries yamle)) 167 - (executable (name test_debug_stale) (modules test_debug_stale) (libraries yamle)) 168 - (executable (name test_error_type) (modules test_error_type) (libraries yamle)) 169 - (executable (name test_a984_minimal) (modules test_a984_minimal) (libraries yamle)) 170 - (executable (name test_indent_debug) (modules test_indent_debug) (libraries yamle)) 171 - (executable (name test_all_mentioned_cases) (modules test_all_mentioned_cases) (libraries yamle)) 172 - (executable (name debug_m2n8) (modules debug_m2n8) (libraries yamle test_suite_lib)) 173 - (executable (name debug_v9d5) (modules debug_v9d5) (libraries yamle test_suite_lib)) 174 - (executable (name test_lhl4) (modules test_lhl4) (libraries yamle)) 175 - (executable (name test_dk4h) (modules test_dk4h) (libraries yamle)) 176 - (executable (name test_sy6v) (modules test_sy6v) (libraries yamle)) 177 - (executable (name test_3hfz) (modules test_3hfz) (libraries yamle)) 178 - (executable (name test_5u3a) (modules test_5u3a) (libraries yamle)) 179 - (executable (name test_2cms) (modules test_2cms) (libraries yamle)) 180 - (executable (name test_basic_yaml) (modules test_basic_yaml) (libraries yamle)) 181 - (executable (name test_loader_debug) (modules test_loader_debug) (libraries yamle test_suite_lib)) 182 - (executable (name test_229q_direct) (modules test_229q_direct) (libraries yamle)) 183 - (executable (name debug_from) (modules debug_from) (libraries yamle)) 184 - (executable (name test_2cms_quick) (modules test_2cms_quick) (libraries yamle)) 185 - (executable (name count_tests) (modules count_tests) (libraries test_suite_lib)) 186 - (executable (name test_bs4k) (modules test_bs4k) (libraries yamle)) 187 - (executable (name test_ks4u) (modules test_ks4u) (libraries yamle)) 188 - (executable (name test_5llu_quick) (modules test_5llu_quick) (libraries yamle)) 189 - (executable (name test_mus6_debug) (modules test_mus6_debug) (libraries yamle)) 190 - (executable (name debug_mus6_load) (modules debug_mus6_load) (libraries yamle test_suite_lib)) 191 - (executable (name debug_mus6_01) (modules debug_mus6_01) (libraries yamle)) 192 - (executable (name debug_dk95_01) (modules debug_dk95_01) (libraries yamle)) 193 - (executable (name debug_y79y_first) (modules debug_y79y_first) (libraries yamle)) 194 - (executable (name debug_y79y_03) (modules debug_y79y_03) (libraries yamle)) 195 - (executable (name debug_y79y_09) (modules debug_y79y_09) (libraries yamle))
+353 -33
yaml/ocaml-yamle/tests/run_all_tests.ml
··· 1 - (* Run all yaml-test-suite tests *) 1 + (* Run all yaml-test-suite tests with optional HTML output *) 2 2 open Yamle 3 3 module TL = Test_suite_lib.Test_suite_loader 4 4 module TF = Test_suite_lib.Tree_format 5 5 6 + (* Configuration - single variable for test suite path *) 6 7 let test_suite_path = "../yaml-test-suite" 7 8 9 + (* HTML escape function *) 10 + let html_escape s = 11 + let buf = Buffer.create (String.length s) in 12 + String.iter (function 13 + | '<' -> Buffer.add_string buf "&lt;" 14 + | '>' -> Buffer.add_string buf "&gt;" 15 + | '&' -> Buffer.add_string buf "&amp;" 16 + | '"' -> Buffer.add_string buf "&quot;" 17 + | c -> Buffer.add_char buf c 18 + ) s; 19 + Buffer.contents buf 20 + 8 21 let normalize_tree s = 9 22 let lines = String.split_on_char '\n' s in 10 23 let lines = List.filter (fun l -> String.trim l <> "") lines in 11 24 String.concat "\n" lines 12 25 13 - let run_test (test : TL.test_case) = 26 + type test_result = { 27 + id : string; 28 + name : string; 29 + yaml : string; 30 + expected_tree : string option; 31 + is_error_test : bool; 32 + status : [`Pass | `Fail of string | `Skip]; 33 + output : string; 34 + } 35 + 36 + let run_test (test : TL.test_case) : test_result = 37 + let base = { 38 + id = test.id; 39 + name = test.name; 40 + yaml = test.yaml; 41 + expected_tree = test.tree; 42 + is_error_test = test.fail; 43 + status = `Skip; 44 + output = ""; 45 + } in 14 46 if test.fail then begin 15 47 try 16 48 let parser = Parser.of_string test.yaml in 17 - let _events = Parser.to_list parser in 18 - `Fail "Expected parsing to fail" 49 + let events = Parser.to_list parser in 50 + let tree = TF.of_spanned_events events in 51 + { base with 52 + status = `Fail "Expected parsing to fail"; 53 + output = tree; 54 + } 19 55 with 20 - | Yamle_error _ -> `Pass 21 - | _ -> `Pass 56 + | Yamle_error e -> 57 + { base with 58 + status = `Pass; 59 + output = Format.asprintf "%a" Error.pp e; 60 + } 61 + | exn -> 62 + { base with 63 + status = `Pass; 64 + output = Printexc.to_string exn; 65 + } 22 66 end 23 67 else begin 24 68 match test.tree with 25 - | None -> `Skip 69 + | None -> 70 + (* No expected tree - check if json indicates expected success *) 71 + (match test.json with 72 + | Some _ -> 73 + (* Has json output, so should parse successfully *) 74 + (try 75 + let parser = Parser.of_string test.yaml in 76 + let events = Parser.to_list parser in 77 + let tree = TF.of_spanned_events events in 78 + { base with status = `Pass; output = tree } 79 + with exn -> 80 + { base with 81 + status = `Fail (Printf.sprintf "Should parse but got: %s" (Printexc.to_string exn)); 82 + output = Printexc.to_string exn; 83 + }) 84 + | None -> 85 + (* No tree, no json, no fail - ambiguous edge case, skip *) 86 + { base with status = `Skip; output = "(no expected tree or json)" }) 26 87 | Some expected -> 27 88 try 28 89 let parser = Parser.of_string test.yaml in ··· 30 91 let actual = TF.of_spanned_events events in 31 92 let expected_norm = normalize_tree expected in 32 93 let actual_norm = normalize_tree actual in 33 - if expected_norm = actual_norm then `Pass 34 - else begin 35 - let msg = Printf.sprintf "Tree mismatch:\nExpected:\n%s\nActual:\n%s" expected_norm actual_norm in 36 - `Fail msg 37 - end 38 - with e -> 39 - let msg = Printexc.to_string e in 40 - `Fail (Printf.sprintf "Exception: %s" msg) 94 + if expected_norm = actual_norm then 95 + { base with status = `Pass; output = actual } 96 + else 97 + { base with 98 + status = `Fail (Printf.sprintf "Tree mismatch"); 99 + output = Printf.sprintf "Expected:\n%s\n\nActual:\n%s" expected_norm actual_norm; 100 + } 101 + with exn -> 102 + { base with 103 + status = `Fail (Printf.sprintf "Exception: %s" (Printexc.to_string exn)); 104 + output = Printexc.to_string exn; 105 + } 41 106 end 42 107 108 + let status_class = function 109 + | `Pass -> "pass" 110 + | `Fail _ -> "fail" 111 + | `Skip -> "skip" 112 + 113 + let status_text = function 114 + | `Pass -> "PASS" 115 + | `Fail _ -> "FAIL" 116 + | `Skip -> "SKIP" 117 + 118 + let generate_html results output_file = 119 + let oc = open_out output_file in 120 + let pass_count = List.length (List.filter (fun r -> r.status = `Pass) results) in 121 + let fail_count = List.length (List.filter (fun r -> match r.status with `Fail _ -> true | _ -> false) results) in 122 + let skip_count = List.length (List.filter (fun r -> r.status = `Skip) results) in 123 + let total = List.length results in 124 + 125 + Printf.fprintf oc {|<!DOCTYPE html> 126 + <html lang="en"> 127 + <head> 128 + <meta charset="UTF-8"> 129 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 130 + <title>Yamle Test Results</title> 131 + <style> 132 + :root { 133 + --pass-color: #22c55e; 134 + --fail-color: #ef4444; 135 + --skip-color: #f59e0b; 136 + --bg-color: #1a1a2e; 137 + --card-bg: #16213e; 138 + --text-color: #e2e8f0; 139 + --border-color: #334155; 140 + } 141 + * { box-sizing: border-box; margin: 0; padding: 0; } 142 + body { 143 + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 144 + background: var(--bg-color); 145 + color: var(--text-color); 146 + line-height: 1.6; 147 + padding: 2rem; 148 + } 149 + .container { max-width: 1400px; margin: 0 auto; } 150 + h1 { margin-bottom: 1.5rem; font-size: 2rem; } 151 + .summary { 152 + display: flex; 153 + gap: 1rem; 154 + margin-bottom: 2rem; 155 + flex-wrap: wrap; 156 + } 157 + .stat { 158 + background: var(--card-bg); 159 + padding: 1rem 1.5rem; 160 + border-radius: 8px; 161 + border-left: 4px solid var(--border-color); 162 + } 163 + .stat.pass { border-left-color: var(--pass-color); } 164 + .stat.fail { border-left-color: var(--fail-color); } 165 + .stat.skip { border-left-color: var(--skip-color); } 166 + .stat-value { font-size: 2rem; font-weight: bold; } 167 + .stat-label { font-size: 0.875rem; opacity: 0.8; } 168 + .filters { 169 + margin-bottom: 1.5rem; 170 + display: flex; 171 + gap: 0.5rem; 172 + flex-wrap: wrap; 173 + } 174 + .filter-btn { 175 + padding: 0.5rem 1rem; 176 + border: 1px solid var(--border-color); 177 + background: var(--card-bg); 178 + color: var(--text-color); 179 + border-radius: 4px; 180 + cursor: pointer; 181 + transition: all 0.2s; 182 + } 183 + .filter-btn:hover { border-color: var(--text-color); } 184 + .filter-btn.active { background: var(--text-color); color: var(--bg-color); } 185 + .search { 186 + padding: 0.5rem 1rem; 187 + border: 1px solid var(--border-color); 188 + background: var(--card-bg); 189 + color: var(--text-color); 190 + border-radius: 4px; 191 + width: 200px; 192 + } 193 + .tests { display: flex; flex-direction: column; gap: 1rem; } 194 + .test { 195 + background: var(--card-bg); 196 + border-radius: 8px; 197 + border: 1px solid var(--border-color); 198 + overflow: hidden; 199 + } 200 + .test-header { 201 + padding: 1rem; 202 + display: flex; 203 + align-items: center; 204 + gap: 1rem; 205 + cursor: pointer; 206 + border-bottom: 1px solid var(--border-color); 207 + } 208 + .test-header:hover { background: rgba(255,255,255,0.05); } 209 + .badge { 210 + padding: 0.25rem 0.5rem; 211 + border-radius: 4px; 212 + font-size: 0.75rem; 213 + font-weight: bold; 214 + text-transform: uppercase; 215 + } 216 + .badge.pass { background: var(--pass-color); color: #000; } 217 + .badge.fail { background: var(--fail-color); color: #fff; } 218 + .badge.skip { background: var(--skip-color); color: #000; } 219 + .badge.error-test { background: #8b5cf6; color: #fff; margin-left: auto; } 220 + .test-id { font-family: monospace; font-weight: bold; } 221 + .test-name { opacity: 0.8; flex: 1; } 222 + .test-content { display: none; padding: 1rem; } 223 + .test.expanded .test-content { display: block; } 224 + .section { margin-bottom: 1rem; } 225 + .section-title { 226 + font-size: 0.875rem; 227 + text-transform: uppercase; 228 + opacity: 0.6; 229 + margin-bottom: 0.5rem; 230 + letter-spacing: 0.05em; 231 + } 232 + pre { 233 + background: #0f172a; 234 + padding: 1rem; 235 + border-radius: 4px; 236 + overflow-x: auto; 237 + font-size: 0.875rem; 238 + white-space: pre-wrap; 239 + word-break: break-all; 240 + } 241 + .expand-icon { transition: transform 0.2s; } 242 + .test.expanded .expand-icon { transform: rotate(90deg); } 243 + </style> 244 + </head> 245 + <body> 246 + <div class="container"> 247 + <h1>Yamle Test Results</h1> 248 + <div class="summary"> 249 + <div class="stat pass"> 250 + <div class="stat-value">%d</div> 251 + <div class="stat-label">Passed</div> 252 + </div> 253 + <div class="stat fail"> 254 + <div class="stat-value">%d</div> 255 + <div class="stat-label">Failed</div> 256 + </div> 257 + <div class="stat skip"> 258 + <div class="stat-value">%d</div> 259 + <div class="stat-label">Skipped</div> 260 + </div> 261 + <div class="stat"> 262 + <div class="stat-value">%d</div> 263 + <div class="stat-label">Total</div> 264 + </div> 265 + </div> 266 + <div class="filters"> 267 + <button class="filter-btn active" data-filter="all">All</button> 268 + <button class="filter-btn" data-filter="pass">Pass</button> 269 + <button class="filter-btn" data-filter="fail">Fail</button> 270 + <button class="filter-btn" data-filter="skip">Skip</button> 271 + <input type="text" class="search" placeholder="Search by ID or name..."> 272 + </div> 273 + <div class="tests"> 274 + |} pass_count fail_count skip_count total; 275 + 276 + List.iter (fun result -> 277 + let error_badge = if result.is_error_test then 278 + {|<span class="badge error-test">Error Test</span>|} 279 + else "" in 280 + Printf.fprintf oc {| <div class="test" data-status="%s" data-id="%s" data-name="%s"> 281 + <div class="test-header" onclick="this.parentElement.classList.toggle('expanded')"> 282 + <span class="expand-icon">▶</span> 283 + <span class="badge %s">%s</span> 284 + <span class="test-id">%s</span> 285 + <span class="test-name">%s</span> 286 + %s 287 + </div> 288 + <div class="test-content"> 289 + <div class="section"> 290 + <div class="section-title">YAML Input</div> 291 + <pre>%s</pre> 292 + </div> 293 + <div class="section"> 294 + <div class="section-title">Yamle Output</div> 295 + <pre>%s</pre> 296 + </div> 297 + </div> 298 + </div> 299 + |} 300 + (status_class result.status) 301 + (html_escape result.id) 302 + (html_escape (String.lowercase_ascii result.name)) 303 + (status_class result.status) 304 + (status_text result.status) 305 + (html_escape result.id) 306 + (html_escape result.name) 307 + error_badge 308 + (html_escape result.yaml) 309 + (html_escape result.output) 310 + ) results; 311 + 312 + Printf.fprintf oc {| </div> 313 + </div> 314 + <script> 315 + document.querySelectorAll('.filter-btn').forEach(btn => { 316 + btn.addEventListener('click', () => { 317 + document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active')); 318 + btn.classList.add('active'); 319 + filterTests(); 320 + }); 321 + }); 322 + document.querySelector('.search').addEventListener('input', filterTests); 323 + function filterTests() { 324 + const filter = document.querySelector('.filter-btn.active').dataset.filter; 325 + const search = document.querySelector('.search').value.toLowerCase(); 326 + document.querySelectorAll('.test').forEach(test => { 327 + const status = test.dataset.status; 328 + const id = test.dataset.id.toLowerCase(); 329 + const name = test.dataset.name; 330 + const matchesFilter = filter === 'all' || status === filter; 331 + const matchesSearch = !search || id.includes(search) || name.includes(search); 332 + test.style.display = matchesFilter && matchesSearch ? '' : 'none'; 333 + }); 334 + } 335 + </script> 336 + </body> 337 + </html> 338 + |}; 339 + close_out oc 340 + 43 341 let () = 342 + let html_output = ref None in 343 + let show_skipped = ref false in 344 + let args = [ 345 + "--html", Arg.String (fun s -> html_output := Some s), 346 + "<file> Generate HTML report to file"; 347 + "--show-skipped", Arg.Set show_skipped, 348 + " Show details of skipped tests"; 349 + ] in 350 + Arg.parse args (fun _ -> ()) "Usage: run_all_tests [--html <file>] [--show-skipped]"; 351 + 44 352 let src_path = Filename.concat test_suite_path "src" in 45 353 let all_tests = TL.load_directory src_path in 46 354 Printf.printf "Total tests loaded: %d\n%!" (List.length all_tests); 47 355 48 - let pass = ref 0 in 49 - let fail = ref 0 in 50 - let skip = ref 0 in 51 - let failures = ref [] in 356 + let results = List.map run_test all_tests in 52 357 53 - List.iter (fun test -> 54 - match run_test test with 55 - | `Pass -> incr pass 56 - | `Skip -> incr skip 57 - | `Fail msg -> 58 - incr fail; 59 - failures := (test.TL.id, test.TL.name, msg) :: !failures 60 - ) all_tests; 358 + let pass_count = List.length (List.filter (fun r -> r.status = `Pass) results) in 359 + let fail_count = List.length (List.filter (fun r -> match r.status with `Fail _ -> true | _ -> false) results) in 360 + let skip_count = List.length (List.filter (fun r -> r.status = `Skip) results) in 61 361 62 362 Printf.printf "\nResults: %d pass, %d fail, %d skip (total: %d)\n%!" 63 - !pass !fail !skip (!pass + !fail + !skip); 363 + pass_count fail_count skip_count (pass_count + fail_count + skip_count); 64 364 65 - if !fail > 0 then begin 365 + if fail_count > 0 then begin 66 366 Printf.printf "\nFailing tests:\n"; 67 - List.iter (fun (id, name, _msg) -> 68 - Printf.printf " %s: %s\n" id name 69 - ) (List.rev !failures) 70 - end 367 + List.iter (fun r -> 368 + match r.status with 369 + | `Fail msg -> Printf.printf " %s: %s - %s\n" r.id r.name msg 370 + | _ -> () 371 + ) results 372 + end; 373 + 374 + if !show_skipped && skip_count > 0 then begin 375 + Printf.printf "\nSkipped tests (no expected tree):\n"; 376 + List.iter (fun r -> 377 + if r.status = `Skip then begin 378 + Printf.printf " %s: %s\n" r.id r.name; 379 + Printf.printf " YAML (%d chars): %S\n" (String.length r.yaml) 380 + (if String.length r.yaml <= 60 then r.yaml 381 + else String.sub r.yaml 0 60 ^ "...") 382 + end 383 + ) results 384 + end; 385 + 386 + match !html_output with 387 + | Some file -> 388 + generate_html results file; 389 + Printf.printf "\nHTML report generated: %s\n" file 390 + | None -> ()
-23
yaml/ocaml-yamle/tests/test_229q_direct.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = In_channel.with_open_text "../yaml-test-suite/src/229Q.yaml" In_channel.input_all in 5 - Printf.printf "YAML length: %d\n" (String.length yaml); 6 - Printf.printf "First 200 chars: %S\n" (String.sub yaml 0 (min 200 (String.length yaml))); 7 - let scanner = Scanner.of_string yaml in 8 - Printf.printf "\nTokens:\n"; 9 - try 10 - let rec loop count = 11 - if count > 30 then Printf.printf " ... (stopped at 30 tokens)\n" 12 - else match Scanner.next scanner with 13 - | None -> Printf.printf " (none)\n" 14 - | Some tok -> 15 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 16 - (Format.asprintf "%a" Token.pp tok.token); 17 - match tok.token with 18 - | Token.Stream_end -> () 19 - | _ -> loop (count + 1) 20 - in 21 - loop 0 22 - with e -> 23 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-12
yaml/ocaml-yamle/tests/test_2cms.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "this\n is\n invalid: x\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - Printf.printf "\nParsing:\n"; 7 - try 8 - let parser = Parser.of_string yaml in 9 - let events = Parser.to_list parser in 10 - Printf.printf "Events: %d (should have errored)\n" (List.length events) 11 - with e -> 12 - Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
-18
yaml/ocaml-yamle/tests/test_2cms_quick.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "this\n is\n invalid: x\n" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - Format.printf "Parsing:@."; 7 - try 8 - let parser = Parser.of_string yaml in 9 - let events = Parser.to_list parser in 10 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 11 - List.iter (fun e -> 12 - Format.printf " %a@." Event.pp e.Event.event 13 - ) events 14 - with 15 - | Yamle_error e -> 16 - Format.printf "Error (expected): %a@." Error.pp e 17 - | e -> 18 - Format.printf "Error: %s@." (Printexc.to_string e)
-25
yaml/ocaml-yamle/tests/test_3hfz.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "---\nkey: value\n... invalid\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - Printf.printf "Byte 18: %C (space=%b, break=%b)\n" 7 - yaml.[18] 8 - (yaml.[18] = ' ' || yaml.[18] = '\t') 9 - (yaml.[18] = '\n' || yaml.[18] = '\r'); 10 - let scanner = Scanner.of_string yaml in 11 - Printf.printf "\nTokens:\n"; 12 - try 13 - let rec loop () = 14 - match Scanner.next scanner with 15 - | None -> Printf.printf " (none)\n" 16 - | Some tok -> 17 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 18 - (Format.asprintf "%a" Token.pp tok.token); 19 - match tok.token with 20 - | Token.Stream_end -> () 21 - | _ -> loop () 22 - in 23 - loop () 24 - with e -> 25 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-29
yaml/ocaml-yamle/tests/test_565n_debug.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "generic: !!binary | 5 - R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 6 - OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ 7 - +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC 8 - AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" in 9 - 10 - let scanner = Scanner.of_string yaml in 11 - let rec find_binary () = 12 - match Scanner.next scanner with 13 - | None -> None 14 - | Some { token; _ } -> 15 - match token with 16 - | Token.Scalar { style = Scalar_style.Literal; value; _ } -> Some value 17 - | _ -> find_binary () 18 - in 19 - match find_binary () with 20 - | None -> Printf.printf "No literal scalar found\n" 21 - | Some value -> 22 - Printf.printf "Got: %S\n" value; 23 - Printf.printf "First char: %C (code %d)\n" value.[0] (Char.code value.[0]); 24 - if value.[0] = ' ' then 25 - Printf.printf "FAIL: starts with space\n" 26 - else if value.[0] = 'R' then 27 - Printf.printf "PASS: starts with R\n" 28 - else 29 - Printf.printf "FAIL: starts with unexpected char\n"
-17
yaml/ocaml-yamle/tests/test_5llu_quick.ml
··· 1 - open Yamle 2 - (* Test 5LLU: Block scalar with wrong indented line after spaces only *) 3 - let () = 4 - (* block scalar: > 5 - ␣ (1 space, empty line) 6 - ␣␣ (2 spaces, empty line) 7 - ␣␣␣ (3 spaces, empty line) 8 - invalid (1 space + content - ERROR!) *) 9 - let yaml = "block scalar: >\n \n \n \n invalid\n" in 10 - Format.printf "YAML: %S@.@." yaml; 11 - try 12 - let parser = Parser.of_string yaml in 13 - let events = Parser.to_list parser in 14 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events) 15 - with 16 - | Yamle_error e -> 17 - Format.printf "Error (expected): %a@." Error.pp e
-11
yaml/ocaml-yamle/tests/test_5u3a.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "key: - a\n - b\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Printf.printf "Events: %d (should have errored)\n" (List.length events) 10 - with e -> 11 - Printf.printf "Error (expected): %s\n" (Printexc.to_string e)
-29
yaml/ocaml-yamle/tests/test_6vjk_debug.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "> 5 - Sammy Sosa completed another 6 - fine season with great stats. 7 - 8 - 63 Home Runs 9 - 0.288 Batting Average 10 - 11 - What a year!" in 12 - Printf.printf "Input YAML:\n%s\n\n" yaml; 13 - 14 - (* Create scanner and get scalar token *) 15 - let scanner = Scanner.of_string yaml in 16 - let rec find_scalar () = 17 - match Scanner.next scanner with 18 - | None -> failwith "No scalar found" 19 - | Some { token; _ } -> 20 - match token with 21 - | Token.Scalar (style, value) -> 22 - Printf.printf "Scalar value: %S\n" value; 23 - Printf.printf "Style: %s\n" (match style with 24 - | Scalar_style.Literal -> "Literal" 25 - | Scalar_style.Folded -> "Folded" 26 - | _ -> "Other") 27 - | _ -> find_scalar () 28 - in 29 - find_scalar ()
-31
yaml/ocaml-yamle/tests/test_6vjk_only.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "> 5 - Sammy Sosa completed another 6 - fine season with great stats. 7 - 8 - 63 Home Runs 9 - 0.288 Batting Average 10 - 11 - What a year!" in 12 - 13 - let scanner = Scanner.of_string yaml in 14 - let rec find_scalar () = 15 - match Scanner.next scanner with 16 - | None -> None 17 - | Some { token; _ } -> 18 - match token with 19 - | Token.Scalar { style = _; value } -> Some value 20 - | _ -> find_scalar () 21 - in 22 - match find_scalar () with 23 - | None -> Printf.printf "No scalar found\n" 24 - | Some value -> 25 - Printf.printf "Got: %S\n" value; 26 - 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 27 - Printf.printf "Expected: %S\n" expected; 28 - if value = expected then 29 - Printf.printf "PASS\n" 30 - else 31 - Printf.printf "FAIL\n"
-25
yaml/ocaml-yamle/tests/test_87e4.ml
··· 1 - open Yamle 2 - 3 - let yaml = {|'implicit block key' : [ 4 - 'implicit flow key' : value, 5 - ]|} 6 - 7 - let () = 8 - Printf.printf "Testing 87E4\n"; 9 - try 10 - let parser = Parser.of_string yaml in 11 - let events = Parser.to_list parser in 12 - Printf.printf "Parsed successfully with %d events\n" (List.length events); 13 - List.iteri (fun i ev -> 14 - Printf.printf "Event %d: " i; 15 - (match ev.Event.event with 16 - | Event.Sequence_start _ -> Printf.printf "Sequence_start" 17 - | Event.Sequence_end -> Printf.printf "Sequence_end" 18 - | Event.Mapping_start _ -> Printf.printf "Mapping_start" 19 - | Event.Mapping_end -> Printf.printf "Mapping_end" 20 - | Event.Scalar {value; _} -> Printf.printf "Scalar(%S)" value 21 - | _ -> Printf.printf "Other"); 22 - Printf.printf "\n" 23 - ) events 24 - with Error.Yamle_error _ -> 25 - Printf.printf "ERROR\n"
-14
yaml/ocaml-yamle/tests/test_a984_minimal.ml
··· 1 - open Yamle 2 - 3 - let test yaml = 4 - Printf.printf "YAML:\n%s\n\n" yaml; 5 - let scanner = Scanner.of_string yaml in 6 - try 7 - while Scanner.next scanner <> None do () done; 8 - Printf.printf "Success!\n" 9 - with e -> 10 - Printf.printf "Error: %s\n" (Printexc.to_string e) 11 - 12 - let () = 13 - test "d:\n e"; 14 - test "a: b\n c\nd:\n e\n f"
-20
yaml/ocaml-yamle/tests/test_a984_trace.ml
··· 1 - (* Trace A984 issue *) 2 - open Yamle 3 - 4 - let show_token tok = 5 - Format.asprintf "%a" Token.pp_spanned tok 6 - 7 - let () = 8 - let yaml = "a: b\n c\nd:\n e\n f" in 9 - Printf.printf "Testing A984:\n%s\n\n" yaml; 10 - let scanner = Scanner.of_string yaml in 11 - Printf.printf "Tokens:\n"; 12 - let rec print_tokens () = 13 - match Scanner.peek scanner with 14 - | None -> Printf.printf "Done\n" 15 - | Some tok -> 16 - Printf.printf " %s\n" (show_token tok); 17 - ignore (Scanner.next scanner); 18 - print_tokens () 19 - in 20 - print_tokens ()
-19
yaml/ocaml-yamle/tests/test_all_mentioned_cases.ml
··· 1 - open Yamle 2 - 3 - let test name yaml = 4 - Printf.printf "\n=== %s ===\n" name; 5 - let scanner = Scanner.of_string yaml in 6 - try 7 - while Scanner.next scanner <> None do () done; 8 - Printf.printf "PASS\n" 9 - with e -> 10 - Printf.printf "FAIL: %s\n" (Printexc.to_string e) 11 - 12 - let () = 13 - (* All cases mentioned in the issue *) 14 - test "565N - Construct Binary" "generic: !!binary |\n R0lGODlh"; 15 - test "A984 - Multiline Scalar" "a: b\n c\nd:\n e\n f"; 16 - test "RZP5 - Trailing Comments" "- #lala\n seq2"; 17 - test "XW4D - Trailing Comments variant" "- #comment\n value"; 18 - test "Q9WF - Separation Spaces" "a: -\tb"; 19 - test "V9D5 - Compact Block Mappings" "- a: b"
-167
yaml/ocaml-yamle/tests/test_anchor_tag_issues.ml
··· 1 - (** Test cases for BU8L, SKE5, RZP5, XW4D *) 2 - 3 - let print_token tok = 4 - match tok.Yamle.Token.token with 5 - | Yamle.Token.Stream_start _ -> "Stream_start" 6 - | Yamle.Token.Stream_end -> "Stream_end" 7 - | Yamle.Token.Document_start -> "Document_start" 8 - | Yamle.Token.Document_end -> "Document_end" 9 - | Yamle.Token.Block_sequence_start -> "Block_sequence_start" 10 - | Yamle.Token.Block_mapping_start -> "Block_mapping_start" 11 - | Yamle.Token.Block_end -> "Block_end" 12 - | Yamle.Token.Flow_sequence_start -> "Flow_sequence_start" 13 - | Yamle.Token.Flow_sequence_end -> "Flow_sequence_end" 14 - | Yamle.Token.Flow_mapping_start -> "Flow_mapping_start" 15 - | Yamle.Token.Flow_mapping_end -> "Flow_mapping_end" 16 - | Yamle.Token.Block_entry -> "Block_entry" 17 - | Yamle.Token.Flow_entry -> "Flow_entry" 18 - | Yamle.Token.Key -> "Key" 19 - | Yamle.Token.Value -> "Value" 20 - | Yamle.Token.Alias name -> "Alias(" ^ name ^ ")" 21 - | Yamle.Token.Anchor name -> "Anchor(" ^ name ^ ")" 22 - | Yamle.Token.Tag { handle; suffix } -> "Tag(" ^ handle ^ suffix ^ ")" 23 - | Yamle.Token.Scalar { value; _ } -> "Scalar(" ^ String.sub value 0 (min 20 (String.length value)) ^ ")" 24 - | Yamle.Token.Version_directive _ -> "Version_directive" 25 - | Yamle.Token.Tag_directive _ -> "Tag_directive" 26 - 27 - let test_bu8l () = 28 - print_endline "Testing BU8L: Node Anchor and Tag on Separate Lines"; 29 - let yaml = {|key: &anchor 30 - !!map 31 - a: b|} in 32 - try 33 - let scanner = Yamle.Scanner.of_string yaml in 34 - let rec print_tokens n = 35 - if n > 30 then (print_endline " ... (stopped at 30 tokens)"; ()) 36 - else 37 - try 38 - match Yamle.Scanner.peek scanner with 39 - | Some { token = Stream_end; _ } as tok -> 40 - Printf.printf " %s\n" (print_token (Option.get tok)); 41 - ignore (Yamle.Scanner.next scanner); 42 - () 43 - | Some tok -> 44 - Printf.printf " %s\n" (print_token tok); 45 - ignore (Yamle.Scanner.next scanner); 46 - print_tokens (n + 1) 47 - | None -> print_endline " (no more tokens)" 48 - with 49 - | Yamle.Error.Yamle_error e -> 50 - Printf.printf " ERROR during scan: %s\n" (Yamle.Error.to_string e); 51 - raise (Yamle.Error.Yamle_error e) 52 - in 53 - print_tokens 0; 54 - print_endline "BU8L: Scanner SUCCESS\n" 55 - with 56 - | Yamle.Error.Yamle_error e -> 57 - Printf.printf "BU8L: FAILED with %s\n\n" (Yamle.Error.to_string e) 58 - | e -> 59 - Printf.printf "BU8L: FAILED with %s\n\n" (Printexc.to_string e) 60 - 61 - let test_ske5 () = 62 - print_endline "Testing SKE5: Anchor before zero indented sequence"; 63 - let yaml = {|--- 64 - seq: 65 - &anchor 66 - - a 67 - - b|} in 68 - try 69 - let scanner = Yamle.Scanner.of_string yaml in 70 - let rec count_tokens n = 71 - match Yamle.Scanner.peek scanner with 72 - | Some { token = Stream_end; _ } -> 73 - ignore (Yamle.Scanner.next scanner); 74 - n 75 - | Some _ -> 76 - ignore (Yamle.Scanner.next scanner); 77 - count_tokens (n + 1) 78 - | None -> n 79 - in 80 - let count = count_tokens 0 in 81 - Printf.printf "SKE5: SUCCESS (tokens: %d)\n\n" count 82 - with 83 - | Yamle.Error.Yamle_error e -> 84 - Printf.printf "SKE5: FAILED with %s\n\n" (Yamle.Error.to_string e) 85 - | e -> 86 - Printf.printf "SKE5: FAILED with %s\n\n" (Printexc.to_string e) 87 - 88 - let test_rzp5 () = 89 - print_endline "Testing RZP5: Various Trailing Comments [1.3]"; 90 - let yaml = {|a: "double 91 - quotes" # lala 92 - b: plain 93 - value # lala 94 - c : #lala 95 - d 96 - ? # lala 97 - - seq1 98 - : # lala 99 - - #lala 100 - seq2 101 - e: &node # lala 102 - - x: y 103 - block: > # lala 104 - abcde|} in 105 - try 106 - let scanner = Yamle.Scanner.of_string yaml in 107 - let rec count_tokens n = 108 - match Yamle.Scanner.peek scanner with 109 - | Some { token = Stream_end; _ } -> 110 - ignore (Yamle.Scanner.next scanner); 111 - n 112 - | Some _ -> 113 - ignore (Yamle.Scanner.next scanner); 114 - count_tokens (n + 1) 115 - | None -> n 116 - in 117 - let count = count_tokens 0 in 118 - Printf.printf "RZP5: SUCCESS (tokens: %d)\n\n" count 119 - with 120 - | Yamle.Error.Yamle_error e -> 121 - Printf.printf "RZP5: FAILED with %s\n\n" (Yamle.Error.to_string e) 122 - | e -> 123 - Printf.printf "RZP5: FAILED with %s\n\n" (Printexc.to_string e) 124 - 125 - let test_xw4d () = 126 - print_endline "Testing XW4D: Various Trailing Comments"; 127 - let yaml = {|a: "double 128 - quotes" # lala 129 - b: plain 130 - value # lala 131 - c : #lala 132 - d 133 - ? # lala 134 - - seq1 135 - : # lala 136 - - #lala 137 - seq2 138 - e: 139 - &node # lala 140 - - x: y 141 - block: > # lala 142 - abcde|} in 143 - try 144 - let scanner = Yamle.Scanner.of_string yaml in 145 - let rec count_tokens n = 146 - match Yamle.Scanner.peek scanner with 147 - | Some { token = Stream_end; _ } -> 148 - ignore (Yamle.Scanner.next scanner); 149 - n 150 - | Some _ -> 151 - ignore (Yamle.Scanner.next scanner); 152 - count_tokens (n + 1) 153 - | None -> n 154 - in 155 - let count = count_tokens 0 in 156 - Printf.printf "XW4D: SUCCESS (tokens: %d)\n\n" count 157 - with 158 - | Yamle.Error.Yamle_error e -> 159 - Printf.printf "XW4D: FAILED with %s\n\n" (Yamle.Error.to_string e) 160 - | e -> 161 - Printf.printf "XW4D: FAILED with %s\n\n" (Printexc.to_string e) 162 - 163 - let () = 164 - test_bu8l (); 165 - test_ske5 (); 166 - test_rzp5 (); 167 - test_xw4d ()
-11
yaml/ocaml-yamle/tests/test_basic_yaml.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "key: value\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let events = Parser.to_list parser in 9 - Printf.printf "Events: %d\n" (List.length events) 10 - with e -> 11 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-18
yaml/ocaml-yamle/tests/test_bs4k.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "word1 # comment\nword2\n" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - Format.printf "Parsing:@."; 7 - try 8 - let parser = Parser.of_string yaml in 9 - let events = Parser.to_list parser in 10 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 11 - List.iter (fun e -> 12 - Format.printf " %a@." Event.pp e.Event.event 13 - ) events 14 - with 15 - | Yamle_error e -> 16 - Format.printf "Error (expected): %a@." Error.pp e 17 - | e -> 18 - Format.printf "Error: %s@." (Printexc.to_string e)
-21
yaml/ocaml-yamle/tests/test_debug_stale.ml
··· 1 - open Yamle 2 - 3 - (* Patch Scanner to add debug output *) 4 - let test yaml = 5 - Printf.printf "YAML:\n%s\n\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - try 8 - let rec loop () = 9 - match Scanner.next scanner with 10 - | None -> Printf.printf "Done\n" 11 - | Some tok -> 12 - Printf.printf "%s\n" (Format.asprintf "%a" Token.pp_spanned tok); 13 - loop () 14 - in 15 - loop () 16 - with e -> 17 - Printf.printf "Error: %s\n" (Printexc.to_string e) 18 - 19 - let () = 20 - (* This should work: simple key, value on next line *) 21 - test "d:\n e"
-21
yaml/ocaml-yamle/tests/test_dk4h.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "---\n[ key\n : value ]\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - Printf.printf "\nTokens:\n"; 8 - try 9 - let rec loop () = 10 - match Scanner.next scanner with 11 - | None -> Printf.printf " (none)\n" 12 - | Some tok -> 13 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 14 - (Format.asprintf "%a" Token.pp tok.token); 15 - match tok.token with 16 - | Token.Stream_end -> () 17 - | _ -> loop () 18 - in 19 - loop () 20 - with e -> 21 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-9
yaml/ocaml-yamle/tests/test_error_type.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "d:\n e" in 5 - let scanner = Scanner.of_string yaml in 6 - try 7 - while Scanner.next scanner <> None do () done 8 - with Error.Yamle_error err -> 9 - Printf.printf "Error: %s\n" (Error.to_string err)
-6
yaml/ocaml-yamle/tests/test_indent_debug.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "d:\n e" in 5 - let scanner = Scanner.of_string yaml in 6 - ignore (Scanner.to_list scanner)
-18
yaml/ocaml-yamle/tests/test_ks4u.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "---\n[\nsequence item\n]\ninvalid item\n" in 5 - Format.printf "YAML: %S@.@." yaml; 6 - Format.printf "Parsing:@."; 7 - try 8 - let parser = Parser.of_string yaml in 9 - let events = Parser.to_list parser in 10 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events); 11 - List.iter (fun e -> 12 - Format.printf " %a@." Event.pp e.Event.event 13 - ) events 14 - with 15 - | Yamle_error e -> 16 - Format.printf "Error (expected): %a@." Error.pp e 17 - | e -> 18 - Format.printf "Error: %s@." (Printexc.to_string e)
-21
yaml/ocaml-yamle/tests/test_lhl4.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "---\n!invalid{}tag scalar\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - Printf.printf "\nTokens:\n"; 8 - try 9 - let rec loop () = 10 - match Scanner.next scanner with 11 - | None -> Printf.printf " (none)\n" 12 - | Some tok -> 13 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 14 - (Format.asprintf "%a" Token.pp tok.token); 15 - match tok.token with 16 - | Token.Stream_end -> () 17 - | _ -> loop () 18 - in 19 - loop () 20 - with e -> 21 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-9
yaml/ocaml-yamle/tests/test_loader_debug.ml
··· 1 - module TL = Test_suite_lib.Test_suite_loader 2 - 3 - let () = 4 - Printf.printf "Testing test loader...\n"; 5 - try 6 - let tests = TL.load_file "../yaml-test-suite/src/229Q.yaml" in 7 - Printf.printf "Loaded %d tests\n" (List.length tests) 8 - with e -> 9 - Printf.printf "Error loading: %s\n" (Printexc.to_string e)
-11
yaml/ocaml-yamle/tests/test_mus6_debug.ml
··· 1 - open Yamle 2 - let () = 3 - let yaml = "%YAML 1.1#...\n---\n" in 4 - Format.printf "YAML: %S@.@." yaml; 5 - try 6 - let parser = Parser.of_string yaml in 7 - let events = Parser.to_list parser in 8 - Format.printf "Events: %d (ERROR: should have failed)@." (List.length events) 9 - with 10 - | Yamle_error e -> 11 - Format.printf "Error (expected): %a@." Error.pp e
-47
yaml/ocaml-yamle/tests/test_nat4_a.ml
··· 1 - (* Test NAT4 case a specifically *) 2 - open Yamle 3 - 4 - let test_case desc yaml expected = 5 - Printf.printf "\n=== %s ===\n" desc; 6 - Printf.printf "Input: %s\n" (String.escaped yaml); 7 - try 8 - let parser = Parser.of_string yaml in 9 - let events = Parser.to_list parser in 10 - List.iter (fun (e : Event.spanned) -> 11 - match e.event with 12 - | Event.Scalar { value; style; _ } -> 13 - Printf.printf "Output: %s (len=%d, style=%s)\n" 14 - (String.escaped value) 15 - (String.length value) 16 - (match style with 17 - | Scalar_style.Single_quoted -> "single" 18 - | Scalar_style.Double_quoted -> "double" 19 - | _ -> "other"); 20 - Printf.printf "Expected: %s (len=%d)\n" (String.escaped expected) (String.length expected); 21 - if value = expected then 22 - Printf.printf "✓ PASS\n" 23 - else 24 - Printf.printf "✗ FAIL\n" 25 - | _ -> () 26 - ) events 27 - with e -> 28 - Printf.printf "Error: %s\n" (Printexc.to_string e) 29 - 30 - let () = 31 - (* NAT4 case a: newline then spaces *) 32 - test_case "a" "a: '\n '" " "; 33 - 34 - (* NAT4 case b: spaces, newline, spaces *) 35 - test_case "b" "a: ' \n '" " "; 36 - 37 - (* NAT4 case e: newline, empty line, spaces *) 38 - test_case "e" "a: '\n\n '" "\n"; 39 - 40 - (* NAT4 case g: newline, two empty lines, spaces *) 41 - test_case "g" "a: '\n\n\n '" "\n\n"; 42 - 43 - (* Simple case: text on both lines *) 44 - test_case "simple" "a: 'foo\nbar'" "foo bar"; 45 - 46 - (* Case with empty line between text *) 47 - test_case "empty_between" "a: 'foo\n\nbar'" "foo\nbar";
-31
yaml/ocaml-yamle/tests/test_remaining.ml
··· 1 - open Yamle 2 - 3 - let test yaml name = 4 - Printf.printf "\n=== %s ===\n" name; 5 - Printf.printf "YAML: %S\n" yaml; 6 - try 7 - let parser = Parser.of_string yaml in 8 - let _ = Parser.to_list parser in 9 - Printf.printf "SUCCESS\n" 10 - with Error.Yamle_error _ -> 11 - Printf.printf "ERROR\n" 12 - 13 - let () = 14 - (* CT4Q: Single Pair Explicit Entry *) 15 - test {|[ 16 - ? foo 17 - bar : baz 18 - ]|} "CT4Q"; 19 - 20 - (* DFF7: Flow Mapping Entries *) 21 - test {|{ 22 - ? explicit: entry, 23 - implicit: entry, 24 - ? 25 - }|} "DFF7"; 26 - 27 - (* FRK4: Completely Empty Flow Nodes *) 28 - test {|{ 29 - ? foo :, 30 - : bar, 31 - }|} "FRK4";
-30
yaml/ocaml-yamle/tests/test_simple_key_debug.ml
··· 1 - open Yamle 2 - 3 - let test_case name yaml = 4 - Printf.printf "\n=== Testing %s ===\n" name; 5 - Printf.printf "YAML:\n%s\n\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - Printf.printf "Tokens:\n"; 8 - let rec print_tokens () = 9 - match Scanner.next scanner with 10 - | None -> Printf.printf "Done\n" 11 - | Some tok -> 12 - Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok); 13 - print_tokens () 14 - in 15 - try 16 - print_tokens () 17 - with e -> 18 - Printf.printf "Error: %s\n" (Printexc.to_string e) 19 - 20 - let () = 21 - (* Test A984 - Multiline Scalar in Mapping *) 22 - test_case "A984" "a: b\n c\nd:\n e\n f"; 23 - 24 - (* Test RZP5 - Trailing Comments *) 25 - test_case "RZP5" "- #lala\n seq2"; 26 - 27 - (* Simplified versions *) 28 - test_case "Simple multiline" "a: b\n c"; 29 - test_case "Simple block entry with comment" "- # comment\n value"; 30 - test_case "After block scalar" "a: |\n text\nb: c"
-21
yaml/ocaml-yamle/tests/test_simple_single.ml
··· 1 - (* Simple test of single-quoted scalar *) 2 - open Yamle 3 - 4 - let () = 5 - let yaml = "'foo\n\nbar'" in 6 - Printf.printf "Input: %s\n" (String.escaped yaml); 7 - 8 - let scanner = Scanner.of_string yaml in 9 - Scanner.iter (fun tok -> 10 - match tok.Token.token with 11 - | Token.Scalar { value; style; _ } -> 12 - Printf.printf "Scalar: %s (len=%d)\n" (String.escaped value) (String.length value); 13 - Printf.printf "Style: %s\n" (match style with 14 - | Scalar_style.Single_quoted -> "single" 15 - | _ -> "other"); 16 - (* Print each character *) 17 - for i = 0 to String.length value - 1 do 18 - Printf.printf " [%d] = %C (code=%d)\n" i value.[i] (Char.code value.[i]) 19 - done 20 - | _ -> () 21 - ) scanner
+3 -1
yaml/ocaml-yamle/tests/test_suite_lib/test_suite_loader.ml
··· 6 6 name : string; 7 7 yaml : string; 8 8 tree : string option; 9 + json : string option; (* If present, indicates test should parse successfully *) 9 10 fail : bool; 10 11 } 11 12 ··· 113 114 | None -> "" 114 115 in 115 116 let tree = extract_mapping_value events "tree" in 117 + let json = extract_mapping_value events "json" in 116 118 let fail = match extract_mapping_value events "fail" with 117 119 | Some "true" -> true 118 120 | _ -> Option.is_some (extract_mapping_value events "error") 119 121 in 120 - { id; name; yaml; tree; fail } 122 + { id; name; yaml; tree; json; fail } 121 123 122 124 (* Load tests from a single YAML file *) 123 125 let load_file path =
-21
yaml/ocaml-yamle/tests/test_sy6v.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - let yaml = "&anchor - sequence entry\n" in 5 - Printf.printf "YAML: %S\n" yaml; 6 - let scanner = Scanner.of_string yaml in 7 - Printf.printf "\nTokens:\n"; 8 - try 9 - let rec loop () = 10 - match Scanner.next scanner with 11 - | None -> Printf.printf " (none)\n" 12 - | Some tok -> 13 - Printf.printf " %d:%d %s\n" tok.span.start.line tok.span.start.column 14 - (Format.asprintf "%a" Token.pp tok.token); 15 - match tok.token with 16 - | Token.Stream_end -> () 17 - | _ -> loop () 18 - in 19 - loop () 20 - with e -> 21 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-24
yaml/ocaml-yamle/tests/test_tokens2.ml
··· 1 - open Yamle 2 - 3 - let yaml = {|'implicit block key' : [ 4 - 'implicit flow key' : value, 5 - ]|} 6 - 7 - let () = 8 - let scanner = Scanner.of_string yaml in 9 - let rec print_all n = 10 - match Scanner.next scanner with 11 - | None -> () 12 - | Some tok -> 13 - Printf.printf "%2d. " n; 14 - (match tok.Token.token with 15 - | Token.Flow_sequence_start -> Printf.printf "Flow_sequence_start" 16 - | Token.Flow_sequence_end -> Printf.printf "Flow_sequence_end" 17 - | Token.Flow_entry -> Printf.printf "Flow_entry" 18 - | Token.Value -> Printf.printf "Value" 19 - | Token.Scalar {value; _} -> Printf.printf "Scalar(%S)" value 20 - | _ -> Printf.printf "Other"); 21 - Printf.printf " at %d:%d\n" tok.span.start.line tok.span.start.column; 22 - print_all (n + 1) 23 - in 24 - print_all 0
-19
yaml/ocaml-yamle/tests/test_trace_a984.ml
··· 1 - open Yamle 2 - 3 - let () = 4 - (* Minimal A984 reproduction *) 5 - let yaml = "d:\n e" in 6 - Printf.printf "Testing minimal A984:\n%s\n\n" yaml; 7 - let scanner = Scanner.of_string yaml in 8 - Printf.printf "Tokens:\n"; 9 - let rec print_tokens () = 10 - match Scanner.next scanner with 11 - | None -> Printf.printf "Done\n" 12 - | Some tok -> 13 - Printf.printf " %s\n" (Format.asprintf "%a" Token.pp_spanned tok); 14 - print_tokens () 15 - in 16 - try 17 - print_tokens () 18 - with e -> 19 - Printf.printf "Error: %s\n" (Printexc.to_string e)
-41
yaml/ocaml-yamle/tests/test_y79y.ml
··· 1 - (* Debug Y79Y test cases *) 2 - open Yamle 3 - 4 - let () = 5 - (* Test case 1: fail=true - tabs at wrong indentation in block scalar *) 6 - let yaml1 = "foo: |\n \t\nbar: 1" in 7 - Printf.printf "=== Test 1 (should fail) ===\n"; 8 - Printf.printf "Input: %S\n" yaml1; 9 - Printf.printf "Visual:\n"; 10 - String.iter (fun c -> 11 - if c = '\t' then Printf.printf "<TAB>" 12 - else if c = '\n' then Printf.printf "<NL>\n" 13 - else Printf.printf "%c" c 14 - ) yaml1; 15 - Printf.printf "\n"; 16 - (try 17 - let parser = Parser.of_string yaml1 in 18 - let events = Parser.to_list parser in 19 - Printf.printf "Events: %d\n" (List.length events); 20 - Printf.printf "ERROR: Should have failed but didn't!\n\n" 21 - with e -> 22 - Printf.printf "Failed as expected: %s\n\n" (Printexc.to_string e)); 23 - 24 - (* Test case 2: should succeed - tab with proper indentation in block scalar *) 25 - let yaml2 = "foo: |\n \t\nbar: 1" in 26 - Printf.printf "=== Test 2 (should succeed) ===\n"; 27 - Printf.printf "Input: %S\n" yaml2; 28 - Printf.printf "Visual:\n"; 29 - String.iter (fun c -> 30 - if c = '\t' then Printf.printf "<TAB>" 31 - else if c = '\n' then Printf.printf "<NL>\n" 32 - else Printf.printf "%c" c 33 - ) yaml2; 34 - Printf.printf "\n"; 35 - (try 36 - let parser = Parser.of_string yaml2 in 37 - let events = Parser.to_list parser in 38 - Printf.printf "Events: %d\n" (List.length events); 39 - Printf.printf "\n" 40 - with e -> 41 - Printf.printf "ERROR: Failed but should succeed: %s\n\n" (Printexc.to_string e))
-68
yaml/ocaml-yamle/tests/test_y79y_all.ml
··· 1 - (* Test all Y79Y cases *) 2 - 3 - let test_case name yaml should_fail = 4 - Printf.printf "=== %s ===\n" name; 5 - try 6 - let scanner = Yamle.Scanner.of_string yaml in 7 - let _tokens = Yamle.Scanner.to_list scanner in 8 - if should_fail then begin 9 - Printf.printf "FAIL: Expected error but parsing succeeded\n"; 10 - false 11 - end else begin 12 - Printf.printf "PASS: Parsing succeeded as expected\n"; 13 - true 14 - end 15 - with e -> 16 - if should_fail then begin 17 - Printf.printf "PASS: Failed as expected (%s)\n" (Printexc.to_string e); 18 - true 19 - end else begin 20 - Printf.printf "FAIL: Unexpected error (%s)\n" (Printexc.to_string e); 21 - false 22 - end 23 - 24 - let () = 25 - let results = ref [] in 26 - 27 - (* Y79Y/00: Tab at start - should FAIL *) 28 - results := test_case "Y79Y/00" "foo: |\n\t\nbar: 1" true :: !results; 29 - 30 - (* Y79Y/01: Tab after 1 space - should PASS *) 31 - results := test_case "Y79Y/01" "foo: |\n \t\nbar: 1" false :: !results; 32 - 33 - (* Y79Y/02: Tab in flow sequence after newline - should PASS *) 34 - results := test_case "Y79Y/02" "- [\n\t\n foo\n ]" false :: !results; 35 - 36 - (* Y79Y/03: Tab immediately after flow start and content - should FAIL *) 37 - results := test_case "Y79Y/03" "- [\n\tfoo,\n foo\n ]" true :: !results; 38 - 39 - (* Y79Y/04: Tab after dash at root level - should FAIL *) 40 - results := test_case "Y79Y/04" "-\t-" true :: !results; 41 - 42 - (* Y79Y/05: Tab after dash with space - should FAIL *) 43 - results := test_case "Y79Y/05" "- \t-" true :: !results; 44 - 45 - (* Y79Y/06: Tab after ? at root level - should FAIL *) 46 - results := test_case "Y79Y/06" "?\t-" true :: !results; 47 - 48 - (* Y79Y/07: Tab after : in explicit mapping - should FAIL *) 49 - results := test_case "Y79Y/07" "? -\n:\t-" true :: !results; 50 - 51 - (* Y79Y/08: Tab after ? before key - should FAIL *) 52 - results := test_case "Y79Y/08" "?\tkey:" true :: !results; 53 - 54 - (* Y79Y/09: Tab after : in explicit mapping - should FAIL *) 55 - results := test_case "Y79Y/09" "? key:\n:\tkey:" true :: !results; 56 - 57 - (* Y79Y/10: Tab before number (content) - should PASS *) 58 - results := test_case "Y79Y/10" "-\t-1" false :: !results; 59 - 60 - Printf.printf "\n=== Summary ===\n"; 61 - let passed = List.filter (fun x -> x) !results |> List.length in 62 - let total = List.length !results in 63 - Printf.printf "%d/%d tests passed\n" passed total; 64 - if passed = total then 65 - Printf.printf "All tests PASSED!\n" 66 - else 67 - Printf.printf "Some tests FAILED\n"; 68 - exit (if passed = total then 0 else 1)
-13
yaml/ocaml-yamle/tests/test_y79y_simple.ml
··· 1 - (* Simple Y79Y test *) 2 - 3 - let () = 4 - (* Test case 1: should fail - tab at wrong indentation *) 5 - let yaml1 = "foo: |\n \t\nbar: 1" in 6 - Printf.printf "=== Test 1 (should fail) ===\n"; 7 - Printf.printf "Testing: %S\n" yaml1; 8 - (try 9 - let scanner = Yamle.Scanner.of_string yaml1 in 10 - let _tokens = Yamle.Scanner.to_list scanner in 11 - Printf.printf "ERROR: Scanning succeeded but should have failed!\n" 12 - with e -> 13 - Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e))
-44
yaml/ocaml-yamle/tests/test_y79y_trace.ml
··· 1 - (* Trace Y79Y test *) 2 - 3 - let test_case yaml desc should_fail expected_scalars = 4 - Printf.printf "=== %s ===\n" desc; 5 - Printf.printf "Testing: %S\n" yaml; 6 - try 7 - let scanner = Yamle.Scanner.of_string yaml in 8 - let tokens = Yamle.Scanner.to_list scanner in 9 - if should_fail then 10 - Printf.printf "ERROR: Expected to fail but got %d tokens\n" (List.length tokens) 11 - else begin 12 - Printf.printf "OK: Got %d tokens\n" (List.length tokens); 13 - let scalars = ref [] in 14 - List.iter (fun (t : Yamle.Token.spanned) -> 15 - match t.token with 16 - | Yamle.Token.Scalar { value; _ } -> 17 - scalars := value :: !scalars; 18 - Printf.printf " Scalar: %S\n" value 19 - | _ -> () 20 - ) tokens; 21 - let scalars = List.rev !scalars in 22 - if scalars <> expected_scalars then begin 23 - Printf.printf "ERROR: Expected scalars %s but got %s\n" 24 - (String.concat ", " (List.map (Printf.sprintf "%S") expected_scalars)) 25 - (String.concat ", " (List.map (Printf.sprintf "%S") scalars)) 26 - end 27 - end 28 - with e -> 29 - if should_fail then 30 - Printf.printf "OK: Failed as expected: %s\n" (Printexc.to_string e) 31 - else 32 - Printf.printf "ERROR: Unexpected failure: %s\n" (Printexc.to_string e) 33 - 34 - let () = 35 - (* Test case 0 (Y79Y): should fail - tab at start of content *) 36 - let yaml0 = "foo: |\n\t\nbar: 1" in 37 - test_case yaml0 "Y79Y/00: tab at start (no spaces)" true []; 38 - Printf.printf "\n"; 39 - 40 - (* Test case 1 (Y79Y/01): should succeed - tab after 1 space indent *) 41 - (* Expected: foo="\t\n", bar="1" *) 42 - let yaml1 = "foo: |\n \t\nbar: 1" in 43 - test_case yaml1 "Y79Y/01: tab after 1 space" false ["foo"; "\t\n"; "bar"; "1"]; 44 - Printf.printf "\n"