Skip to content

Commit ea8a5f2

Browse files
authored
Convert more tests to the node test runner (rescript-lang#6978)
* Convert more tests to the node test runner * CHANGELOG
1 parent 897cc22 commit ea8a5f2

29 files changed

+3457
-3854
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#### :house: Internal
3434

3535
- Add dev container. https://github.com/rescript-lang/rescript-compiler/pull/6962
36+
- Convert more tests to the node test runner. https://github.com/rescript-lang/rescript-compiler/pull/6956
3637

3738
# 12.0.0-alpha.1
3839

@@ -95,7 +96,7 @@
9596
- Remove the transformation of `foo(1,2)` into `Js.Internal.opaqueFullApply(Internal.opaque(f), 1, 2)`, and change the back-end to treat all applications as uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6893
9697
- Remove `@uncurry` from ReScript sources (others, tests). https://github.com/rescript-lang/rescript-compiler/pull/6938
9798
- Remove leftover uncurried handling. https://github.com/rescript-lang/rescript-compiler/pull/6939 https://github.com/rescript-lang/rescript-compiler/pull/6940
98-
- Use node test runner instead of mocha. https://github.com/rescript-lang/rescript-compiler/pull/6956
99+
- Start converting tests from mocha to the node test runner. https://github.com/rescript-lang/rescript-compiler/pull/6956
99100

100101
#### :nail_care: Polish
101102

jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js

+3-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/belt_float_ntest.js

+23-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/belt_float_ntest.res

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
open Node_test
2+
open Node_test_util
23

34
module F = Belt.Float
45

5-
let eq = (loc, a, b) => Node_assert.equal(a, b, ~message=loc)
6-
76
describe("Belt.Float", () => {
87
test("fromInt", () => {
98
eq(__LOC__, F.fromInt(1), 1.0)

jscomp/test/belt_hashmap_ntest.js

+96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/belt_hashmap_ntest.res

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
open Node_test
2+
open Node_test_util
3+
4+
module N = Belt.HashMap
5+
module S = Belt.Map.Int
6+
module I = Array_data_util
7+
module A = Belt.Array
8+
module So = Belt.SortArray
9+
10+
let intEq = (x: int, y) => x == y
11+
let intHash = (x: int) => Hashtbl.hash(x)
12+
let cmp = (x: int, y) => compare(x, y)
13+
module Y = unpack(Belt.Id.hashable(~eq=intEq, ~hash=intHash))
14+
let empty: N.t<int, int, _> = N.make(~id=module(Y), ~hintSize=30)
15+
16+
describe("Belt.HashMap", () => {
17+
test("fromArray", () => {
18+
let u = A.concat(I.randomRange(30, 100), I.randomRange(40, 120))
19+
let v = A.zip(u, u)
20+
let xx = N.fromArray(~id=module(Y), v)
21+
eq(__LOC__, N.size(xx), 91)
22+
eq(__LOC__, So.stableSortBy(N.keysToArray(xx), cmp), I.range(30, 120))
23+
})
24+
25+
test("mergeMany", () => {
26+
N.mergeMany(empty, [(1, 1), (2, 3), (3, 3), (2, 2)])
27+
eq(__LOC__, N.get(empty, 2), Some(2))
28+
eq(__LOC__, N.size(empty), 3)
29+
})
30+
31+
test("remove", () => {
32+
let u = A.concat(I.randomRange(0, 100_000), I.randomRange(0, 100))
33+
let v = N.make(~id=module(Y), ~hintSize=40)
34+
N.mergeMany(v, A.zip(u, u))
35+
eq(__LOC__, N.size(v), 100_001)
36+
for i in 0 to 1_000 {
37+
N.remove(v, i)
38+
}
39+
eq(__LOC__, N.size(v), 99_000)
40+
for i in 0 to 2_000 {
41+
N.remove(v, i)
42+
}
43+
eq(__LOC__, N.size(v), 98_000)
44+
ok(__LOC__, A.every(I.range(2_001, 100_000), x => N.has(v, x)))
45+
})
46+
})

jscomp/test/belt_hashset_int_ntest.js

+91
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)