-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy patharray_subtle_test.js
141 lines (116 loc) · 2.29 KB
/
array_subtle_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
'use strict';
var Mt = require("./mt.js");
var Caml_array = require("../../lib/js/caml_array.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: x,
_1: y
};
})
],
tl: suites.contents
};
}
var v = [
1,
2,
3,
3
];
eq("File \"array_subtle_test.res\", line 11, characters 12-19", [
4,
v.length
]);
eq("File \"array_subtle_test.res\", line 14, characters 5-12", [
5,
v.push(3)
]);
eq("File \"array_subtle_test.res\", line 15, characters 5-12", [
5,
v.length
]);
eq("File \"array_subtle_test.res\", line 16, characters 5-12", [
5,
v.length
]);
eq("File \"array_subtle_test.res\", line 20, characters 5-12", [
3,
Caml_array.get(v, 2)
]);
Caml_array.set(v, 2, 4);
eq("File \"array_subtle_test.res\", line 22, characters 5-12", [
4,
Caml_array.get(v, 2)
]);
while(v.length > 0) {
v.pop();
};
eq("File \"array_subtle_test.res\", line 29, characters 5-12", [
0,
v.length
]);
function f(v) {
var x = v.pop();
if (x !== undefined) {
console.log("hi");
} else {
console.log("hi2");
}
console.log((v.pop(), undefined));
}
function fff(x) {
return true;
}
function fff2(x) {
if (x.length >= 10) {
console.log("hi");
return ;
}
}
function fff3(x) {
return 1;
}
function fff4(x) {
if (x.length !== 0) {
return 1;
} else {
return 2;
}
}
eq("File \"array_subtle_test.res\", line 61, characters 3-10", [
fff3([]),
1
]);
eq("File \"array_subtle_test.res\", line 62, characters 3-10", [
fff4([]),
2
]);
eq("File \"array_subtle_test.res\", line 63, characters 3-10", [
fff4([1]),
1
]);
Mt.from_pair_suites("Array_subtle_test", suites.contents);
exports.suites = suites;
exports.test_id = test_id;
exports.eq = eq;
exports.v = v;
exports.f = f;
exports.fff = fff;
exports.fff2 = fff2;
exports.fff3 = fff3;
exports.fff4 = fff4;
/* Not a pure module */