Skip to content

Commit 93110d0

Browse files
committed
test(array): add tests for non-native functions
1 parent c8a67b5 commit 93110d0

File tree

5 files changed

+434
-4
lines changed

5 files changed

+434
-4
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
"clean": "rescript clean",
66
"build": "rescript",
77
"watch": "rescript build -w",
8-
"test": "node test/PromiseTest.mjs && node test/TempTests.mjs"
8+
"test": "node test/TestSuite.mjs && node test/TempTests.mjs"
99
},
10-
"keywords": [
11-
"rescript"
12-
],
10+
"keywords": ["rescript"],
1311
"homepage": "https://github.com/rescript-association/rescript-core",
1412
"author": "ReScript Team",
1513
"license": "MIT",

test/ArrayTests.mjs

Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
import * as Test from "./Test.mjs";
4+
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
5+
import * as Core__List from "../src/Core__List.mjs";
6+
import * as Core__Array from "../src/Core__Array.mjs";
7+
8+
var eq = Caml_obj.equal;
9+
10+
Test.run([
11+
[
12+
"ArrayTests.res",
13+
5,
14+
20,
15+
26
16+
],
17+
"make"
18+
], Core__Array.make(6, 7), eq, [
19+
7,
20+
7,
21+
7,
22+
7,
23+
7,
24+
7
25+
]);
26+
27+
Test.run([
28+
[
29+
"ArrayTests.res",
30+
8,
31+
13,
32+
30
33+
],
34+
"fromInitializer"
35+
], Core__Array.fromInitializer(7, (function (i) {
36+
return i + 3 | 0;
37+
})), eq, [
38+
3,
39+
4,
40+
5,
41+
6,
42+
7,
43+
8,
44+
9
45+
]);
46+
47+
Test.run([
48+
[
49+
"ArrayTests.res",
50+
14,
51+
20,
52+
28
53+
],
54+
"reduce"
55+
], Core__Array.reduce([
56+
1,
57+
2,
58+
3
59+
], /* [] */0, Core__List.add), eq, {
60+
hd: 3,
61+
tl: {
62+
hd: 2,
63+
tl: {
64+
hd: 1,
65+
tl: /* [] */0
66+
}
67+
}
68+
});
69+
70+
Test.run([
71+
[
72+
"ArrayTests.res",
73+
15,
74+
20,
75+
36
76+
],
77+
"reduce - empty"
78+
], Core__Array.reduce([], /* [] */0, Core__List.add), eq, /* [] */0);
79+
80+
Test.run([
81+
[
82+
"ArrayTests.res",
83+
18,
84+
13,
85+
28
86+
],
87+
"reduceReverse"
88+
], Core__Array.reduceReverse([
89+
1,
90+
2,
91+
3
92+
], /* [] */0, Core__List.add), eq, {
93+
hd: 1,
94+
tl: {
95+
hd: 2,
96+
tl: {
97+
hd: 3,
98+
tl: /* [] */0
99+
}
100+
}
101+
});
102+
103+
Test.run([
104+
[
105+
"ArrayTests.res",
106+
23,
107+
20,
108+
43
109+
],
110+
"reduceReverse - empty"
111+
], Core__Array.reduceReverse([], /* [] */0, Core__List.add), eq, /* [] */0);
112+
113+
Test.run([
114+
[
115+
"ArrayTests.res",
116+
25,
117+
20,
118+
38
119+
],
120+
"shuffle - length"
121+
], Core__Array.shuffle([
122+
1,
123+
2,
124+
3
125+
]).length, eq, 3);
126+
127+
var arr = [
128+
1,
129+
2,
130+
3
131+
];
132+
133+
Test.run([
134+
[
135+
"ArrayTests.res",
136+
28,
137+
13,
138+
38
139+
],
140+
"shuffleInPlace - length"
141+
], (Core__Array.shuffleInPlace(arr), arr.length), eq, 3);
142+
143+
Test.run([
144+
[
145+
"ArrayTests.res",
146+
39,
147+
13,
148+
24
149+
],
150+
"filterMap"
151+
], Core__Array.filterMap([
152+
1,
153+
2,
154+
3,
155+
4,
156+
5,
157+
6
158+
], (function (n) {
159+
if (n % 2 === 0) {
160+
return Math.imul(n, n);
161+
}
162+
163+
})), eq, [
164+
4,
165+
16,
166+
36
167+
]);
168+
169+
Test.run([
170+
[
171+
"ArrayTests.res",
172+
44,
173+
20,
174+
42
175+
],
176+
"filterMap - no match"
177+
], Core__Array.filterMap([
178+
1,
179+
2,
180+
3,
181+
4,
182+
5,
183+
6
184+
], (function (param) {
185+
186+
})), eq, []);
187+
188+
Test.run([
189+
[
190+
"ArrayTests.res",
191+
46,
192+
13,
193+
32
194+
],
195+
"filterMap - empty"
196+
], Core__Array.filterMap([], (function (n) {
197+
if (n % 2 === 0) {
198+
return Math.imul(n, n);
199+
}
200+
201+
})), eq, []);
202+
203+
Test.run([
204+
[
205+
"ArrayTests.res",
206+
52,
207+
20,
208+
30
209+
],
210+
"keepSome"
211+
], Core__Array.keepSome([
212+
1,
213+
undefined,
214+
3
215+
]), eq, [
216+
1,
217+
3
218+
]);
219+
220+
Test.run([
221+
[
222+
"ArrayTests.res",
223+
54,
224+
13,
225+
34
226+
],
227+
"keepSome - all Some"
228+
], Core__Array.keepSome([
229+
1,
230+
2,
231+
3
232+
]), eq, [
233+
1,
234+
2,
235+
3
236+
]);
237+
238+
Test.run([
239+
[
240+
"ArrayTests.res",
241+
59,
242+
20,
243+
41
244+
],
245+
"keepSome - all None"
246+
], Core__Array.keepSome([
247+
undefined,
248+
undefined,
249+
undefined
250+
]), eq, []);
251+
252+
Test.run([
253+
[
254+
"ArrayTests.res",
255+
60,
256+
20,
257+
38
258+
],
259+
"keepSome - empty"
260+
], Core__Array.keepSome([]), eq, []);
261+
262+
Test.run([
263+
[
264+
"ArrayTests.res",
265+
63,
266+
13,
267+
22
268+
],
269+
"findMap"
270+
], Core__Array.findMap([
271+
1,
272+
2,
273+
3,
274+
4,
275+
5,
276+
6
277+
], (function (n) {
278+
if (n % 2 === 0) {
279+
return n - 8 | 0;
280+
}
281+
282+
})), eq, -6);
283+
284+
Test.run([
285+
[
286+
"ArrayTests.res",
287+
68,
288+
20,
289+
40
290+
],
291+
"findMap - no match"
292+
], Core__Array.findMap([
293+
1,
294+
2,
295+
3,
296+
4,
297+
5,
298+
6
299+
], (function (param) {
300+
301+
})), eq, undefined);
302+
303+
Test.run([
304+
[
305+
"ArrayTests.res",
306+
70,
307+
13,
308+
30
309+
],
310+
"findMap - empty"
311+
], Core__Array.findMap([], (function (n) {
312+
if (n % 2 === 0) {
313+
return Math.imul(n, n);
314+
}
315+
316+
})), eq, undefined);
317+
318+
export {
319+
eq ,
320+
}
321+
/* Not a pure module */

0 commit comments

Comments
 (0)