Skip to content

Commit 559f0d7

Browse files
committed
Test: test static evaluation of switches
1 parent 7b6f4bd commit 559f0d7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

compiler/tests-compiler/static_eval.ml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,36 @@ let%expect_test "static eval of string get" =
157157
}
158158
}
159159
//end |}]
160+
161+
let%expect_test "static eval of tags" =
162+
let program =
163+
compile_and_parse
164+
{|
165+
166+
type t = A | B | C of t | D of t
167+
168+
let foobar =
169+
let x = C (D A) in
170+
match x with
171+
| A -> 1
172+
| B -> 2
173+
| C _ -> 2
174+
| D _ -> 3
175+
176+
let export = [|foobar;foobar|]
177+
|}
178+
in
179+
print_program program;
180+
[%expect
181+
{|
182+
(function(globalThis){
183+
"use strict";
184+
var
185+
runtime = globalThis.jsoo_runtime,
186+
export$0 = [0, 2, 2],
187+
Test = [0, 2, export$0];
188+
runtime.caml_register_global(1, Test, "Test");
189+
return;
190+
}
191+
(globalThis));
192+
//end |}]

0 commit comments

Comments
 (0)