Skip to content

Commit e6e56ff

Browse files
committed
Update extension tests
1 parent ea07802 commit e6e56ff

File tree

2 files changed

+65
-9
lines changed

2 files changed

+65
-9
lines changed

jscomp/test/record_extension_test.js

Lines changed: 54 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/record_extension_test.res

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

33
let suites: ref<Mt.pair_suites> = ref(list{})
44
let 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 */
88
type t0 = ..
99
type t0 += Inline_record({x: int, y: string})
10+
type t0 += SinglePayload(string) | TuplePayload(int, string)
1011

1112
let 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 */
2125
type 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+
5563
let () = Mt.from_pair_suites(__LOC__, suites.contents)

0 commit comments

Comments
 (0)