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 */ */
22
33let suites : ref <Mt .pair_suites > = ref (list {})
44let test_id = ref (0 )
@@ -7,15 +7,19 @@ let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y)
77/* Record_extension */
88type t0 = ..
99type t0 += Inline_record ({x : int , y : string })
10+ type t0 += SinglePayload (string ) | TuplePayload (int , string )
1011
1112let f = x =>
1213 switch x {
1314 | 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 ))
1417 | _ => None
1518 }
16- let v0 = Inline_record ({x : 3 , y : "4" })
1719
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 ))
1923
2024/* Record_unboxed */
2125type t1 = | @unboxed A ({x : int })
@@ -52,4 +56,8 @@ let u = f =>
5256 | _ => - 1
5357 }
5458
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+
5563let () = Mt .from_pair_suites (__LOC__ , suites .contents )
0 commit comments