mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
test: update parser test
This commit is contained in:
parent
8866f032fe
commit
6e423e3f75
3 changed files with 35 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
(tests
|
||||
(names p1)
|
||||
(flags :standard -open Sidekick_util -open Sidekick_parser)
|
||||
(libraries sidekick.util sidekick.parser))
|
||||
(package sidekick-parser)
|
||||
(libraries sidekick.util sidekick-parser))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
t1: f (g x) y
|
||||
loc(t1): at line 0, column 0 - at line 0, column 9
|
||||
t2: let x := 1 in (f (f x 2))
|
||||
loc(t2): at line 0, column 0 - at line 0, column 21
|
||||
loc(t1): at line 1, column 0 - at line 1, column 9
|
||||
t2: let x := 1 in f (f x 2)
|
||||
loc(t2): at line 1, column 0 - at line 1, column 22
|
||||
t3: let l := map f (list 1 2 3) in let l2 := rev l in = (rev l2) l
|
||||
loc(t3): at line 1, column 1 - at line 1, column 61
|
||||
t4: let assm := ==> (is_foo p) (= (filter p l) nil) in true
|
||||
loc(t4): at line 1, column 0 - at line 1, column 51
|
||||
t5: let
|
||||
f := lam (x : int) (y : int) (z : bool). (= (+ x y) z) and
|
||||
g := lam x. (f (f x)) in
|
||||
is_g g
|
||||
loc(t5): at line 1, column 0 - at line 1, column 84
|
||||
|
|
|
|||
|
|
@ -1,20 +1,24 @@
|
|||
module P = Parse_term
|
||||
module P = Parse_util
|
||||
module A = Ast_term
|
||||
|
||||
(*
|
||||
let () = Printexc.record_backtrace true
|
||||
*)
|
||||
let () = Printexc.record_backtrace true
|
||||
|
||||
let () =
|
||||
Printexc.register_printer (function
|
||||
| Parser_comb.ParseError e -> Some (Parser_comb.Error.to_string e)
|
||||
| P.Exn_parse_error e -> Some (P.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 t = P.term_of_string s in
|
||||
match t with
|
||||
| Ok t ->
|
||||
Fmt.printf "%s: %a@." what A.pp_term t;
|
||||
Fmt.printf "loc(%s): %a@." what Loc.pp (A.loc t)
|
||||
| Error err ->
|
||||
Fmt.printf "FAIL:@ error while parsing %S:@ %a@." what P.Error.pp err
|
||||
|
||||
let () = test_str "t1" "f (g x) y"
|
||||
let () = test_str "t2" "let x:= 1 in f (f x 2)"
|
||||
|
|
@ -23,5 +27,15 @@ let () =
|
|||
test_str "t3"
|
||||
{|
|
||||
let l := map f (list 1 2 3) in
|
||||
let l2 := rev l in eq (rev l2) l
|
||||
let l2 := rev l in rev l2 = l
|
||||
|}
|
||||
|
||||
let () =
|
||||
test_str "t4" {|let assm := is_foo p ==> (filter p l = nil) in true
|
||||
|}
|
||||
|
||||
let () =
|
||||
test_str "t5"
|
||||
{|let f := fn (x y : int) (z:bool). ( x+ y) = z
|
||||
and g := fn x. f (f x) in is_g g
|
||||
|}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue