open Sexp
open ClosTrans
+exception Syntax_error of string
+
let symbol = function
Symbol n -> n
| _ -> failwith "expected symbol"
let compile_string string =
compile @@ Stream.of_string string
+
+exception Syntax_error of string
+
val compile : char Stream.t -> ClosTrans.program
val compile_string : string -> ClosTrans.program
let ok x y =
OUnit.assert_equal ~printer:(string_of_list $ List.map ClosTrans.to_string) x y
+let syntax_error f =
+ try
+ f ();
+ assert_failure "not raise"
+ with Syntax_error _ ->
+ assert_bool "raised" true
+
let _ =
("lisp module test" >::: [
"empty" >::
"slot-set!" >::
(fun () ->
ok (result (SlotSet (Var "obj","name",Int 42))) @@
- Lisp.compile_string "(slot-set! obj name 42)")
+ Lisp.compile_string "(slot-set! obj name 42)");
+ "syntax error" >::
+ (fun () ->
+ syntax_error (fun () ->
+ Lisp.compile_string "(if a)"))
]) +> run_test_tt
-
-
-
--- /dev/null
+open Base
+open OUnit
+open Util
+
+let inc x =
+ x + 1
+
+let _ =
+ ("Tuple" >:::
+ ["T2" >::: [
+ "map1" >::
+ (fun () ->
+ ok (2,1) @@ Tuple.T2.map1 inc (1,1));
+ "map2" >::
+ (fun () ->
+ ok (1,2) @@ Tuple.T2.map2 inc (1,1));
+ ];
+ "T3" >::: [
+ "map1" >::
+ (fun () ->
+ ok (2,1,1) @@ Tuple.T3.map1 inc (1,1,1));
+ "map2" >::
+ (fun () ->
+ ok (1,2,1) @@ Tuple.T3.map2 inc (1,1,1));
+ "map3" >::
+ (fun () ->
+ ok (1,1,2) @@ Tuple.T3.map3 inc (1,1,1));
+ ]
+ ]) +> run_test_tt
+