forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast_abstract_test.ml
101 lines (73 loc) · 1.47 KB
/
ast_abstract_test.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
let suites : Mt.pair_suites ref = ref []
let test_id = ref 0
let eq loc x y =
incr test_id ;
suites :=
(loc ^" id " ^ (string_of_int !test_id), (fun _ -> Mt.Eq(x,y))) :: !suites
type 'a t =
{
x : int ;
y : bool;
z : 'a
}
[@@bs.deriving {jsConverter = newType} ]
let v0 = tToJs { x = 3 ; y = false; z = false}
let v1 = tToJs { x = 3 ; y = false; z = ""}
type x =
[`a
|`b
|`c]
[@@bs.deriving {jsConverter = newType}]
let idx v = eq __LOC__ (xFromJs (xToJs v)) v
let x0 = xToJs `a
let x1 = xToJs `b
let () =
idx `a ;
idx `b;
idx `c
type a =
| A
| B [@bs.as 3]
| C
[@@bs.deriving {jsConverter = newType}]
let id x =
eq __LOC__ (aFromJs (aToJs x )) x
let a0 = aToJs A
let a1 = aToJs B
let () =
id A ;
id B ;
id C
type b =
| D0
| D1
| D2
| D3
[@@bs.deriving {jsConverter = newType }]
let b0 = bToJs D0
let b1 = bToJs D1
let idb v =
eq __LOC__ (bFromJs (bToJs v )) v
let () = idb D0; idb D1; idb D2 ; idb D3
type c =
| D0 [@bs.as 3]
| D1
| D2
| D3
[@@bs.deriving {jsConverter = {newType }}]
let c0 = cToJs D0
let idc v = eq __LOC__ (cFromJs (cToJs v)) v
let () = idc D0; idc D1 ; idc D2; idc D3
type h =
| JsMapperEraseType
| B [@@bs.deriving {accessors; jsConverter = newType} ]
type z =
| ZFromJs
| ZToJs
| ZXx (* not overridden *)
[@@bs.deriving {
accessors;
jsConverter
}
]
;; Mt.from_pair_suites __MODULE__ !suites