File: gh_1307.ml

package info (click to toggle)
js-of-ocaml 5.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,020 kB
  • sloc: ml: 91,250; javascript: 57,289; ansic: 315; makefile: 271; lisp: 23; sh: 6; perl: 4
file content (31 lines) | stat: -rw-r--r-- 788 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let test content =
  Printf.printf "input: %S\n" content;
  flush_all ();
  match Parser_1307.root Lexer_1307.token (Lexing.from_string content) with
  | n ->
      Printf.printf "%d\n" n;
      print_endline "success"
  | exception e ->
      print_endline (Printexc.to_string e);
      print_endline "failure"

let%expect_test "parsing" =
  (* use [Parsing.set_trace true] once https://github.com/janestreet/ppx_expect/issues/43 is fixed *)
  let (old : bool) = Parsing.set_trace false in
  test "a";
  [%expect {|
    input: "a"
    Stdlib.Parsing.Parse_error
    failure |}];
  test "aa";
  [%expect {|
    input: "aa"
    0
    success |}];
  test "aaa";
  [%expect {|
    input: "aaa"
    Stdlib.Parsing.Parse_error
    failure |}];
  let (_ : bool) = Parsing.set_trace old in
  ()