Initial packaging
[pkg-ocaml-deriving-ocsigen.git] / tests / typeable_tests.ml
blob59047038b4dce61878b9b7ba4e31d12b61a75eb6
1 (*pp deriving *)
3 open Deriving_Typeable
5 type t1 = F deriving (Typeable)
6 type t2 = F deriving (Typeable)
8 let eq_types = TypeRep.eq
10 let _ =
11 begin
12 assert (eq_types
13 (Typeable_t1.type_rep ())
14 (Typeable_t1.type_rep ()));
15 assert (eq_types
16 (Typeable_t2.type_rep ())
17 (Typeable_t2.type_rep ()));
18 assert (not (eq_types
19 (Typeable_t1.type_rep ())
20 (Typeable_t2.type_rep ())));
21 assert (not (eq_types
22 (Typeable_t2.type_rep ())
23 (Typeable_t1.type_rep ())));
24 end
26 type t3 = int deriving (Typeable)
28 let _ =
29 begin
30 assert (eq_types
31 (Typeable_int.type_rep ())
32 (Typeable_t3.type_rep ()));
33 end
36 type t4 = [`T of int] deriving (Typeable)
37 type t5 = [`T of t3] deriving (Typeable)
39 let _ =
40 begin
41 assert (eq_types
42 (Typeable_t4.type_rep ())
43 (Typeable_t5.type_rep ()));
44 end
46 type t6 = [`T of t5]
47 deriving (Typeable)
49 let _ =
50 begin
51 assert (not (eq_types
52 (Typeable_t5.type_rep ())
53 (Typeable_t6.type_rep ())));
55 end
57 type t7 = [`T of t6]
58 deriving (Typeable)
60 let _ =
61 begin
62 assert (not (eq_types
63 (Typeable_t6.type_rep ())
64 (Typeable_t7.type_rep ())));
65 end
68 type t8 = [`A | `B] deriving (Typeable)
69 type t9 = [`B | `A] deriving (Typeable)
71 let _ =
72 begin
73 assert (eq_types
74 (Typeable_t8.type_rep ())
75 (Typeable_t9.type_rep ()));
76 end
79 type ('a,'r) openr = [`Nil | `Cons of 'a * 'r]
80 deriving (Typeable)
81 type 'a closedr = [`Nil | `Cons of 'a * 'a closedr]
82 deriving (Typeable)
83 type l1 = (int, l1) openr
84 and l2 = int closedr deriving (Typeable)
86 let _ =
87 begin
88 assert (eq_types
89 (Typeable_l1.type_rep ())
90 (Typeable_l1.type_rep ()));
91 end
93 type nil = [`Nil] deriving (Typeable)
94 type t10 = ([nil| `Cons of int * 'a ] as 'a) list
95 deriving (Typeable)
96 type t11 = l2 list deriving (Typeable)
98 let _ =
99 begin
100 assert
101 (eq_types
102 (Typeable_t10.type_rep ())
103 (Typeable_t11.type_rep ()));