forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptional_ffi_test.js
147 lines (116 loc) · 2.23 KB
/
optional_ffi_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
var Mt = require("./mt.js");
var Caml_option = require("../../lib/js/caml_option.js");
var suites = {
contents: /* [] */0
};
var test_id = {
contents: 0
};
function eq(loc, param) {
var y = param[1];
var x = param[0];
test_id.contents = test_id.contents + 1 | 0;
suites.contents = {
hd: [
loc + (" id " + String(test_id.contents)),
(function (param) {
return {
TAG: /* Eq */0,
_0: x,
_1: y
};
})
],
tl: suites.contents
};
}
function hey(x, y) {
if (x === void 0) { x = 3; }
return x + y;
}
;
var u = hey(undefined, 3);
var z = hey(5, 3);
eq("File \"optional_ffi_test.ml\", line 23, characters 5-12", [
[
u,
z
],
[
6,
8
]
]);
var counter = {
contents: 0
};
function side_effect(x) {
x.contents = x.contents + 1 | 0;
return x.contents;
}
function bug_to_fix(f, x) {
return hey(f(x), 3);
}
function bug_to_fix2(f, x) {
return hey(Caml_option.option_get(f(x)), 3);
}
var counter2 = {
contents: 0
};
function side_effect2(x) {
x.contents = x.contents + 1 | 0;
return x.contents;
}
var v = bug_to_fix(side_effect, counter);
var pair_0 = [
v,
counter.contents
];
var pair_1 = [
4,
1
];
var pair = [
pair_0,
pair_1
];
var v2 = bug_to_fix2(side_effect2, counter2);
var pair2_0 = [
v2,
counter.contents
];
var pair2_1 = [
4,
1
];
var pair2 = [
pair2_0,
pair2_1
];
eq("File \"optional_ffi_test.ml\", line 43, characters 5-12", pair);
eq("File \"optional_ffi_test.ml\", line 44, characters 5-12", pair2);
function heystr(x, y) {
if (x === void 0) { x = "3"; }
return x + y;
}
;
var pair_1$1 = heystr("name", "4");
var pair$1 = [
"name4",
pair_1$1
];
eq("File \"optional_ffi_test.ml\", line 58, characters 5-12", pair$1);
Mt.from_pair_suites("Optional_ffi_test", suites.contents);
exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
exports.u = u;
exports.z = z;
exports.counter = counter;
exports.side_effect = side_effect;
exports.bug_to_fix = bug_to_fix;
exports.bug_to_fix2 = bug_to_fix2;
exports.counter2 = counter2;
exports.side_effect2 = side_effect2;
/* Not a pure module */