Skip to content

Commit 99e81e2

Browse files
committed
add tests
1 parent ed3dccb commit 99e81e2

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

jscomp/test/arity_infer.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
3+
var Curry = require("../../lib/js/curry.js");
4+
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
5+
6+
function f0(x) {
7+
var tmp;
8+
if (x > 3) {
9+
tmp = (function (x) {
10+
return x + 1 | 0;
11+
});
12+
} else {
13+
throw Caml_builtin_exceptions.not_found;
14+
}
15+
return tmp(3);
16+
}
17+
18+
function f1(x) {
19+
throw Caml_builtin_exceptions.not_found;
20+
return Curry._1(undefined, x);
21+
}
22+
23+
function f3(x) {
24+
var tmp;
25+
if (x > 3 || x < 0) {
26+
throw Caml_builtin_exceptions.not_found;
27+
} else {
28+
switch (x) {
29+
case 0 :
30+
tmp = (function (x) {
31+
return x + 1 | 0;
32+
});
33+
break;
34+
case 1 :
35+
tmp = (function (x) {
36+
return x + 2 | 0;
37+
});
38+
break;
39+
case 2 :
40+
tmp = (function (x) {
41+
return x + 3 | 0;
42+
});
43+
break;
44+
case 3 :
45+
tmp = (function (x) {
46+
return x + 4 | 0;
47+
});
48+
break;
49+
50+
}
51+
}
52+
return tmp(3);
53+
}
54+
55+
exports.f0 = f0;
56+
exports.f1 = f1;
57+
exports.f3 = f3;
58+
/* No side effect */

jscomp/test/arity_infer.ml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
3+
4+
5+
let f0 x =
6+
(if x > 3 then fun x -> x + 1
7+
else (raise Not_found)) 3
8+
9+
10+
let f1 x =
11+
(raise Not_found : _ -> _ ) x
12+
13+
14+
let f3 x =
15+
(match x with
16+
| 0 -> fun x -> x + 1
17+
| 1 -> fun x -> x + 2
18+
| 2 -> fun x -> x + 3
19+
| 3 -> fun x -> x + 4
20+
| _ -> raise Not_found
21+
) 3

0 commit comments

Comments
 (0)