Skip to content

Commit 5c63ff4

Browse files
hhugovouillon
authored andcommitted
fix test
1 parent 09f0bd4 commit 5c63ff4

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

compiler/tests-compiler/call_gen.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ module M1 = struct
8282
function m(_e_,_f_){return k(_d_,_c_,_e_,_f_)}
8383
//end
8484
function caml_call1(f,a0)
85-
{return f.length == 1?f(a0):runtime.caml_call_gen(f,[a0])}
85+
{return (f.l >= 0?f.l:f.l = f.length) == 1
86+
?f(a0)
87+
:runtime.caml_call_gen(f,[a0])}
8688
//end
8789
function caml_call2(f,a0,a1)
88-
{return f.length == 2?f(a0,a1):runtime.caml_call_gen(f,[a0,a1])}
90+
{return (f.l >= 0?f.l:f.l = f.length) == 2
91+
?f(a0,a1)
92+
:runtime.caml_call_gen(f,[a0,a1])}
8993
//end
9094
|}]
9195
end

compiler/tests-compiler/gh1051.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ let%expect_test _ =
3535
{|
3636
Warning: integer overflow: integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
3737
function caml_call2(f,a0,a1)
38-
{return f.length == 2?f(a0,a1):runtime.caml_call_gen(f,[a0,a1])}
38+
{return (f.l >= 0?f.l:f.l = f.length) == 2
39+
?f(a0,a1)
40+
:runtime.caml_call_gen(f,[a0,a1])}
3941
//end |}];
4042
()

compiler/tests-compiler/gh1354.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ with Exit ->
5050
runtime=globalThis.jsoo_runtime,
5151
caml_wrap_exception=runtime.caml_wrap_exception;
5252
function caml_call2(f,a0,a1)
53-
{return f.length == 2?f(a0,a1):runtime.caml_call_gen(f,[a0,a1])}
53+
{return (f.l >= 0?f.l:f.l = f.length) == 2
54+
?f(a0,a1)
55+
:runtime.caml_call_gen(f,[a0,a1])}
5456
var
5557
global_data=runtime.caml_get_global_data(),
5658
Stdlib=global_data.Stdlib,
@@ -108,7 +110,9 @@ with Exit ->
108110
caml_string_of_jsbytes=runtime.caml_string_of_jsbytes,
109111
caml_wrap_exception=runtime.caml_wrap_exception;
110112
function caml_call3(f,a0,a1,a2)
111-
{return f.length == 3?f(a0,a1,a2):runtime.caml_call_gen(f,[a0,a1,a2])}
113+
{return (f.l >= 0?f.l:f.l = f.length) == 3
114+
?f(a0,a1,a2)
115+
:runtime.caml_call_gen(f,[a0,a1,a2])}
112116
var
113117
global_data=runtime.caml_get_global_data(),
114118
Stdlib=global_data.Stdlib,
@@ -179,7 +183,9 @@ with Exit ->
179183
caml_string_of_jsbytes=runtime.caml_string_of_jsbytes,
180184
caml_wrap_exception=runtime.caml_wrap_exception;
181185
function caml_call2(f,a0,a1)
182-
{return f.length == 2?f(a0,a1):runtime.caml_call_gen(f,[a0,a1])}
186+
{return (f.l >= 0?f.l:f.l = f.length) == 2
187+
?f(a0,a1)
188+
:runtime.caml_call_gen(f,[a0,a1])}
183189
var
184190
global_data=runtime.caml_get_global_data(),
185191
Stdlib=global_data.Stdlib,

compiler/tests-compiler/lambda_lifting.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Printf.printf "%d\n" (f 3)
3535
:runtime.caml_trampoline_return(f,[a0,a1])}
3636
function caml_cps_call3(f,a0,a1,a2)
3737
{return runtime.caml_stack_check_depth()
38-
?f.length == 3?f(a0,a1,a2):runtime.caml_call_gen(f,[a0,a1,a2])
38+
?(f.l >= 0?f.l:f.l = f.length) == 3
39+
?f(a0,a1,a2)
40+
:runtime.caml_call_gen(f,[a0,a1,a2])
3941
:runtime.caml_trampoline_return(f,[a0,a1,a2])}
4042
return runtime.caml_callback
4143
(function(cont)

lib/tests/test_fun_call.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let s x =
2828
if(x === undefined)
2929
return "undefined"
3030
if(typeof x === "function")
31-
return "function#" + x.length
31+
return "function#" + x.length + "#" + x.l
3232
if(x.toString() == "[object Arguments]")
3333
return "(Arguments: " + Array.prototype.slice.call(x).toString() + ")";
3434
return x.toString()
@@ -96,7 +96,7 @@ let%expect_test "partial application, 0 argument call is treated like 1 argument
9696
let%expect_test _ =
9797
let plus = Js.wrap_callback (fun a b -> a + b) in
9898
call_and_log plus {| (function(f){ return f(1) }) |};
99-
[%expect {| Result: function#0 |}];
99+
[%expect {| Result: function#0#undefined |}];
100100
call_and_log plus {| (function(f){ return f(1)(2) }) |};
101101
[%expect {| Result: 3 |}];
102102
call_and_log plus {| (function(f){ return f(1,2) }) |};
@@ -147,7 +147,7 @@ let%expect_test "wrap_callback_strict" =
147147
(Js.Unsafe.callback_with_arity 2 cb3)
148148
{| (function(f){ return f(1,2,3) }) |};
149149
[%expect {|
150-
Result: function#0 |}];
150+
Result: function#1#1 |}];
151151
call_and_log
152152
(Js.Unsafe.callback_with_arity 2 cb3)
153153
~cont:(fun g -> g 4)
@@ -164,7 +164,7 @@ let%expect_test "wrap_callback_strict" =
164164
Result: 0 |}];
165165
call_and_log (Js.Unsafe.callback_with_arity 2 cb3) {| (function(f){ return f(1,2) }) |};
166166
[%expect {|
167-
Result: function#0 |}]
167+
Result: function#1#1 |}]
168168

169169
let%expect_test "wrap_callback_strict" =
170170
call_and_log
@@ -238,7 +238,7 @@ let%expect_test "partial application, 0 argument call is treated 1 argument (und
238238
let%expect_test _ =
239239
let plus = Js.wrap_meth_callback (fun _ a b -> a + b) in
240240
call_and_log plus {| (function(f){ return f(1) }) |};
241-
[%expect {| Result: function#0 |}];
241+
[%expect {| Result: function#0#undefined |}];
242242
call_and_log plus {| (function(f){ return f(1)(2) }) |};
243243
[%expect {| Result: 3 |}];
244244
call_and_log plus {| (function(f){ return f(1,2) }) |};
@@ -291,7 +291,7 @@ let%expect_test "wrap_meth_callback_strict" =
291291
(Js.Unsafe.meth_callback_with_arity 2 cb4)
292292
{| (function(f){ return f.apply("this",[1,2,3]) }) |};
293293
[%expect {|
294-
Result: function#0 |}];
294+
Result: function#1#1 |}];
295295
call_and_log
296296
(Js.Unsafe.meth_callback_with_arity 2 cb4)
297297
~cont:(fun g -> g 4)
@@ -309,7 +309,7 @@ let%expect_test "wrap_meth_callback_strict" =
309309
call_and_log
310310
(Js.Unsafe.meth_callback_with_arity 2 cb4)
311311
{| (function(f){ return f.apply("this",[1,2]) }) |};
312-
[%expect {| Result: function#0 |}]
312+
[%expect {| Result: function#1#1 |}]
313313

314314
let%expect_test "wrap_meth_callback_strict" =
315315
call_and_log
@@ -354,7 +354,7 @@ let%expect_test "partial application, extra arguments set to undefined" =
354354
let%expect_test _ =
355355
call_and_log cb3 ~cont:(fun g -> g 1) {| (function(f){ return f }) |};
356356
[%expect {|
357-
Result: function#0 |}]
357+
Result: function#2#2 |}]
358358

359359
let%expect_test _ =
360360
call_and_log cb3 ~cont:(fun g -> g 1 2 3 4) {| (function(f){ return f }) |};
@@ -369,7 +369,7 @@ let%expect_test _ =
369369
| _ -> Printf.printf "Error: unknown"
370370
in
371371
f cb5;
372-
[%expect {| Result: function#0 |}];
372+
[%expect {| Result: function#1#1 |}];
373373
f cb4;
374374
[%expect {|
375375
got 1, 1, 2, 3, done
@@ -399,7 +399,7 @@ let%expect_test _ =
399399
Result: 0 |}];
400400
f (Obj.magic cb4);
401401
[%expect {|
402-
Result: function#0 |}];
402+
Result: function#1#1 |}];
403403
f (Obj.magic cb5);
404404
[%expect {|
405-
Result: function#0 |}]
405+
Result: function#2#2 |}]

0 commit comments

Comments
 (0)