Skip to content

Commit 5362ff4

Browse files
committed
Update testsuite for dynamic switching
1 parent 49e7c91 commit 5362ff4

13 files changed

+520
-270
lines changed

compiler/tests-compiler/direct_calls.ml

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -123,53 +123,91 @@ let%expect_test "direct calls with --enable effects" =
123123
M1.f 1; M2.f 2
124124
|}
125125
in
126-
print_fun_decl code (Some "test1");
127-
print_fun_decl code (Some "test2");
128-
print_fun_decl code (Some "test3");
129-
print_fun_decl code (Some "test4");
126+
print_fun_decl code (Some "test1$0");
127+
print_fun_decl code (Some "test1$1");
128+
print_var_decl code "test1";
129+
print_fun_decl code (Some "test2$0");
130+
print_fun_decl code (Some "test2$1");
131+
print_var_decl code "test2";
132+
print_fun_decl code (Some "test3$0");
133+
print_fun_decl code (Some "test3$1");
134+
print_var_decl code "test3";
135+
print_fun_decl code (Some "test4$0");
136+
print_fun_decl code (Some "test4$1");
137+
print_var_decl code "test4";
130138
[%expect
131139
{|
132-
function test1(param, cont){
133-
function f(g, x){return g(x);}
134-
var _k_ = 7;
135-
f(function(x){return x + 1 | 0;}, _k_);
136-
var _l_ = 4.;
137-
f(function(x){return x * 2.;}, _l_);
140+
function test1$0(param){
141+
function f(g, x){return caml_call1(g, x);}
142+
var _H_ = 7;
143+
f(function(x){return x + 1 | 0;}, _H_);
144+
var _I_ = 4.;
145+
f(function(x){return x * 2.;}, _I_);
146+
return 0;
147+
}
148+
//end
149+
function test1$1(param, cont){
150+
function f(g, x){return caml_call1(g, x);}
151+
var _F_ = 7;
152+
f(function(x){return x + 1 | 0;}, _F_);
153+
var _G_ = 4.;
154+
f(function(x){return x * 2.;}, _G_);
138155
return cont(0);
139156
}
140157
//end
141-
function test2(param, cont){
142-
function f(g, x, cont){return caml_cps_exact_call2(g, x, cont);}
143-
var _f_ = 7;
144-
function _g_(x, cont){return cont(x + 1 | 0);}
158+
var test1 = caml_cps_closure(test1$0, test1$1);
159+
//end
160+
function test2$0(param){
161+
var f = f$0();
162+
f(_h_(), 7);
163+
f(_j_(), cst_a);
164+
return 0;
165+
}
166+
//end
167+
function test2$1(param, cont){
168+
var f = f$0(), _y_ = 7, _z_ = _h_();
145169
return caml_cps_exact_call3
146170
(f,
147-
_g_,
148-
_f_,
149-
function(_h_){
150-
function _i_(x, cont){
151-
return caml_cps_call3(Stdlib[28], x, cst_a$0, cont);
152-
}
171+
_z_,
172+
_y_,
173+
function(_A_){
174+
var _B_ = _j_();
153175
return caml_cps_exact_call3
154-
(f, _i_, cst_a, function(_j_){return cont(0);});
176+
(f, _B_, cst_a, function(_C_){return cont(0);});
155177
});
156178
}
157179
//end
158-
function test3(x, cont){
180+
var test2 = caml_cps_closure(test2$0, test2$1);
181+
//end
182+
function test3$0(x){
159183
function F(symbol){function f(x){return x + 1 | 0;} return [0, f];}
160-
var M1 = F([0]), M2 = F([0]), _e_ = M2[1].call(null, 2);
161-
return cont([0, M1[1].call(null, 1), _e_]);
184+
var M1 = F([0]), M2 = F([0]), _x_ = caml_call1(M2[1], 2);
185+
return [0, caml_call1(M1[1], 1), _x_];
162186
}
163187
//end
164-
function test4(x, cont){
165-
function F(symbol){
166-
function f(x, cont){return caml_cps_call3(Stdlib_Printf[2], _a_, x, cont);}
167-
return [0, f];
168-
}
169-
var M1 = F([0]), M2 = F([0]), _b_ = 1, _c_ = M1[1];
188+
function test3$1(x, cont){
189+
function F(symbol){function f(x){return x + 1 | 0;} return [0, f];}
190+
var M1 = F([0]), M2 = F([0]), _w_ = M2[1].call(null, 2);
191+
return cont([0, M1[1].call(null, 1), _w_]);
192+
}
193+
//end
194+
var test3 = caml_cps_closure(test3$0, test3$1);
195+
//end
196+
function test4$0(x){
197+
function F(symbol){var f$0 = f(); return [0, f$0];}
198+
var M1 = F([0]), M2 = F([0]);
199+
caml_call1(M1[1], 1);
200+
return caml_call1(M2[1], 2);
201+
}
202+
//end
203+
function test4$1(x, cont){
204+
function F(symbol){var f$0 = f(); return [0, f$0];}
205+
var M1 = F([0]), M2 = F([0]), _t_ = 1, _u_ = M1[1];
170206
return caml_cps_exact_call2
171-
(_c_,
172-
_b_,
173-
function(_d_){return caml_cps_exact_call2(M2[1], 2, cont);});
207+
(_u_,
208+
_t_,
209+
function(_v_){return caml_cps_exact_call2(M2[1], 2, cont);});
174210
}
211+
//end
212+
var test4 = caml_cps_closure(test4$0, test4$1);
175213
//end |}]

compiler/tests-compiler/effects.ml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,35 @@ let fff () =
3939
| e -> None) }
4040
|}
4141
in
42-
print_fun_decl program (Some "fff");
42+
(*ignore @@ Js_of_ocaml_compiler.(Js_output.program (Pretty_print.to_out_channel stdout) program);*)
43+
print_fun_decl program (Some "fff$0");
44+
print_fun_decl program (Some "fff$1");
45+
print_var_decl program "fff";
4346
[%expect
4447
{|
45-
function fff(param, cont){
48+
function fff$0(param){
4649
var
47-
_b_ =
48-
[0,
49-
function(e, cont){
50-
return e === E
51-
? cont([0, function(k, cont){return cont(11);}])
52-
: cont(0);
53-
}],
54-
_c_ = 10;
55-
function _d_(x, cont){return cont(x);}
56-
var _e_ = Stdlib_Effect[3][5];
50+
_p_ = [0, _d_()],
51+
_q_ = _f_(),
52+
_r_ = caml_call3(Stdlib_Effect[3][5], _q_, 10, _p_);
53+
return caml_call1(caml_call1(Stdlib_Printf[2], _h_), _r_);
54+
}
55+
//end
56+
function fff$1(param, cont){
57+
var _i_ = [0, _d_()], _k_ = _f_(), _j_ = 10, _l_ = Stdlib_Effect[3][5];
5758
return caml_cps_call4
58-
(_e_,
59-
_d_,
60-
_c_,
61-
_b_,
62-
function(_f_){
63-
var _g_ = Stdlib_Printf[2];
59+
(_l_,
60+
_k_,
61+
_j_,
62+
_i_,
63+
function(_m_){
64+
var _n_ = Stdlib_Printf[2];
6465
return caml_cps_call2
65-
(_g_,
66-
_a_,
67-
function(_h_){return caml_cps_call2(_h_, _f_, cont);});
66+
(_n_,
67+
_h_,
68+
function(_o_){return caml_cps_call2(_o_, _m_, cont);});
6869
});
6970
}
71+
//end
72+
var fff = caml_cps_closure(fff$0, fff$1);
7073
//end |}]

0 commit comments

Comments
 (0)