valueTests.ml 1.72 KB
Newer Older
Pietro Abate's avatar
Pietro Abate committed
1
open OUnit2
2
3
open Testlib

Pietro Abate's avatar
Pietro Abate committed
4
5

(* Typed -> Lambda *)
6
7
8
9
let run_test_compile msg expected totest _ =
  let expected,_ = parse_texpr_lexpr expected in
  let totest,_ = parse_cduce_lexpr totest in
  assert_equal ~msg:msg ~printer:(fun x -> Lambda.Print.lambda_to_string x) expected totest
Pietro Abate's avatar
Pietro Abate committed
10
11
12

let tests_poly_abstr = [
  "Test CDuce.lambda.const_abstr failed",
13
14
  "fun f x : Int : Int -> 2",
  "fun f (x : Int) : Int = 2";
15
16

  "Test CDuce.lambda.let",
17
  "let x : Int = 3 in x : Int",
18
19
  "let x : Int = 3 in x : Int";

20
21
(*

22
23
24
  "Test CDuce.lambda.identity",
  "",
  "(fun f x : 'A : 'A -> x)[{A/Int}].2";
Pietro Abate's avatar
WIP    
Pietro Abate committed
25

26
   "Test CDuce.runtime.misc.partial",
Pietro Abate's avatar
WIP    
Pietro Abate committed
27
  "",
28
29
  "fun applier x : 'A f : ('A -> 'A) : 'A -> f.x";

30
31
32
  "Test CDuce.lambda.apply",
  "",
  "(fun f x : Int : Int -> x).2";
Pietro Abate's avatar
WIP    
Pietro Abate committed
33
34
35
36
37
38
39
40
  
  "Test CDuce.lambda.applier",
  "",
  "fun applier x : Int f : (Int->Int) : Int -> f.x";
  
  "Test CDuce.runtime.misc.applier_applied failed",
  "",
  "((fun applier x : Int f : (Int->Int) : Int -> f.x).2).(fun g x : Int : Int -> x)";
41

Pietro Abate's avatar
WIP    
Pietro Abate committed
42
43
44
45
  "Test CDuce.lambda.applier poly",
  "",
  "fun applier x : 'A f : ('A -> Int) : Int -> f.x";
 *)
Pietro Abate's avatar
Pietro Abate committed
46
47
48
49
50
51
];;

let tests_compile = "CDuce compile tests (Typed -> Lambda )" >:::
  List.map (fun (m,e,f) -> f >:: run_test_compile m e f) tests_poly_abstr

(* Typed -> Lambda -> Value *)
52
53
54
let run_test_eval msg expected totest _ =
  let expected = parse_texpr_vexpr expected in
  let totest = parse_cduce_vexpr totest in
55
  assert_equal ~msg:msg ~printer:(fun x -> x) (Value.value_to_string expected) (Value.value_to_string totest)
Pietro Abate's avatar
Pietro Abate committed
56
57
58
59
60
61
62

let tests_eval = "CDuce evaluation tests (Typed -> Lambda -> Value )" >:::
  List.map (fun (m,e,f) -> f >:: run_test_eval m e f) tests_poly_abstr

let _ =
  run_test_tt_main (
    test_list
Pietro Abate's avatar
WIP    
Pietro Abate committed
63
      [ (* tests_compile; *)
Pietro Abate's avatar
Pietro Abate committed
64
65
66
67
        tests_eval 
      ]
  )
;;