mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-08 12:15:48 -05:00
test: basic test for parser
This commit is contained in:
parent
1c2c9deefd
commit
ea755e5bc6
3 changed files with 26 additions and 0 deletions
4
unittest/parser/dune
Normal file
4
unittest/parser/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
(tests
|
||||||
|
(names p1)
|
||||||
|
(flags :standard -open Sidekick_util -open Sidekick_parser)
|
||||||
|
(libraries sidekick.util sidekick.parser))
|
||||||
20
unittest/parser/p1.ml
Normal file
20
unittest/parser/p1.ml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
module P = Parse_term
|
||||||
|
module A = Ast_term
|
||||||
|
|
||||||
|
(*
|
||||||
|
let () = Printexc.record_backtrace true
|
||||||
|
*)
|
||||||
|
|
||||||
|
let () =
|
||||||
|
Printexc.register_printer (function
|
||||||
|
| Parser_comb.ParseError e -> Some (Parser_comb.Error.to_string e)
|
||||||
|
| _ -> None)
|
||||||
|
|
||||||
|
let test_str what s =
|
||||||
|
let t = P.of_string_exn s in
|
||||||
|
|
||||||
|
Fmt.printf "%s: %a@." what A.pp_term t;
|
||||||
|
Fmt.printf "loc(%s): %a@." what A.pp_loc (A.loc t)
|
||||||
|
|
||||||
|
let () = test_str "t1" "f (g x) y"
|
||||||
|
let () = test_str "t2" "let x:= 1 in f (f x 2)"
|
||||||
2
unittest/parser/t1.expected
Normal file
2
unittest/parser/t1.expected
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue