1
- /* for o in jscomp/test/*test.js ; do npx mocha $o ; done */ */
1
+ /* for o in jscomp/test/*test.js ; do npx mocha $o ; done */ */
2
2
3
3
let suites : ref <Mt .pair_suites > = ref (list {})
4
4
let test_id = ref (0 )
@@ -7,15 +7,19 @@ let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y)
7
7
/* Record_extension */
8
8
type t0 = ..
9
9
type t0 += Inline_record ({x : int , y : string })
10
+ type t0 += SinglePayload (string ) | TuplePayload (int , string )
10
11
11
12
let f = x =>
12
13
switch x {
13
14
| Inline_record ({x , y }) => Some (x + int_of_string (y ))
15
+ | SinglePayload (v ) => Some (int_of_string (v ))
16
+ | TuplePayload (v0 , v1 ) => Some (v0 + int_of_string (v1 ))
14
17
| _ => None
15
18
}
16
- let v0 = Inline_record ({x : 3 , y : "4" })
17
19
18
- eq (__LOC__ , f (v0 ), Some (7 ))
20
+ eq (__LOC__ , f (Inline_record ({x : 3 , y : "4" })), Some (7 ))
21
+ eq (__LOC__ , f (SinglePayload ("1" )), Some (1 ))
22
+ eq (__LOC__ , f (TuplePayload (1 , "2" )), Some (3 ))
19
23
20
24
/* Record_unboxed */
21
25
type t1 = | @unboxed A ({x : int })
@@ -52,4 +56,8 @@ let u = f =>
52
56
| _ => - 1
53
57
}
54
58
59
+ eq (__LOC__ , u (() => raise (A ({name : 1 , x : 1 }))), 2 )
60
+ eq (__LOC__ , u (() => raise (B (1 , 2 ))), 3 )
61
+ eq (__LOC__ , u (() => raise (C ({name : 4 }))), 4 )
62
+
55
63
let () = Mt .from_pair_suites (__LOC__ , suites .contents )
0 commit comments