Skip to content

Commit bcbeeab

Browse files
authored
Start using node test runner instead of mocha (rescript-lang#6956)
* Start using node test runner instead of mocha * CHANGELOG
1 parent 30bda6a commit bcbeeab

19 files changed

+285
-368
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
- 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
9090
- Remove `@uncurry` from ReScript sources (others, tests). https://github.com/rescript-lang/rescript-compiler/pull/6938
9191
- Remove leftover uncurried handling. https://github.com/rescript-lang/rescript-compiler/pull/6939 https://github.com/rescript-lang/rescript-compiler/pull/6940
92+
- Use node test runner instead of mocha. https://github.com/rescript-lang/rescript-compiler/pull/6956
9293

9394
#### :nail_care: Polish
9495

jscomp/test/Assert.js

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

jscomp/test/Assert.res

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@module("node:assert") external ok: (bool, ~message: string=?) => unit = "ok"
2+
@module("node:assert") external equal: ('a, 'a, ~message: string=?) => unit = "strictEqual"
3+
@module("node:assert") external deepEqual: ('a, 'a, ~message: string=?) => unit = "deepStrictEqual"
4+
@module("node:assert")
5+
external notDeepEqual: ('a, 'a, ~message: string=?) => unit = "notDeepStrictEqual"
6+
@module("node:assert") external fail: (~message: string=?) => unit = "fail"

jscomp/test/NodeTest.js

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

jscomp/test/NodeTest.res

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@module("node:test")
2+
external test: (string, unit => unit) => unit = "test"
3+
4+
@module("node:test")
5+
external describe: (string, unit => unit) => unit = "describe"

jscomp/test/belt_float_ntest.js

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

jscomp/test/belt_float_ntest.res

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
open NodeTest
2+
3+
module F = Belt.Float
4+
5+
let eq = (loc, a, b) => Assert.equal(a, b, ~message=loc)
6+
7+
describe("Belt.Float", () => {
8+
test("fromInt", () => {
9+
eq(__LOC__, F.fromInt(1), 1.0)
10+
eq(__LOC__, F.fromInt(-1), -1.0)
11+
})
12+
13+
test("toInt", () => {
14+
eq(__LOC__, F.toInt(1.0), 1)
15+
eq(__LOC__, F.toInt(1.3), 1)
16+
eq(__LOC__, F.toInt(1.7), 1)
17+
eq(__LOC__, F.toInt(-1.0), -1)
18+
eq(__LOC__, F.toInt(-1.5), -1)
19+
eq(__LOC__, F.toInt(-1.7), -1)
20+
})
21+
22+
test("fromString", () => {
23+
eq(__LOC__, F.fromString("1"), Some(1.0))
24+
eq(__LOC__, F.fromString("-1"), Some(-1.0))
25+
eq(__LOC__, F.fromString("1.7"), Some(1.7))
26+
eq(__LOC__, F.fromString("-1.0"), Some(-1.0))
27+
eq(__LOC__, F.fromString("-1.5"), Some(-1.5))
28+
eq(__LOC__, F.fromString("-1.7"), Some(-1.7))
29+
eq(__LOC__, F.fromString("not a float"), None)
30+
})
31+
32+
test("toString", () => {
33+
eq(__LOC__, F.toString(1.0), "1")
34+
eq(__LOC__, F.toString(-1.0), "-1")
35+
eq(__LOC__, F.toString(-1.5), "-1.5")
36+
})
37+
38+
test("operators", () => {
39+
open! F
40+
eq(__LOC__, 2.0 + 3.0, 5.0)
41+
eq(__LOC__, 2.0 - 3.0, -1.0)
42+
eq(__LOC__, 2.0 * 3.0, 6.0)
43+
eq(__LOC__, 3.0 / 2.0, 1.5)
44+
})
45+
})

jscomp/test/belt_int_ntest.js

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

jscomp/test/belt_int_ntest.res

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
open NodeTest
2+
3+
module I = Belt.Int
4+
5+
let eq = (loc, a, b) => Assert.equal(a, b, ~message=loc)
6+
7+
describe("Belt.Int", () => {
8+
test("toFloat", () => {
9+
eq(__LOC__, I.toFloat(1), 1.0)
10+
eq(__LOC__, I.toFloat(-1), -1.0)
11+
})
12+
13+
test("fromFloat", () => {
14+
eq(__LOC__, I.fromFloat(1.0), 1)
15+
eq(__LOC__, I.fromFloat(1.3), 1)
16+
eq(__LOC__, I.fromFloat(1.7), 1)
17+
eq(__LOC__, I.fromFloat(-1.0), -1)
18+
eq(__LOC__, I.fromFloat(-1.5), -1)
19+
eq(__LOC__, I.fromFloat(-1.7), -1)
20+
})
21+
22+
test("fromString", () => {
23+
eq(__LOC__, I.fromString("1"), Some(1))
24+
eq(__LOC__, I.fromString("-1"), Some(-1))
25+
eq(__LOC__, I.fromString("1.7"), Some(1))
26+
eq(__LOC__, I.fromString("-1.0"), Some(-1))
27+
eq(__LOC__, I.fromString("-1.5"), Some(-1))
28+
eq(__LOC__, I.fromString("-1.7"), Some(-1))
29+
eq(__LOC__, I.fromString("not an int"), None)
30+
})
31+
32+
test("toString", () => {
33+
eq(__LOC__, I.toString(1), "1")
34+
eq(__LOC__, I.toString(-1), "-1")
35+
})
36+
37+
test("operators", () => {
38+
open! I
39+
40+
eq(__LOC__, 2 + 3, 5)
41+
eq(__LOC__, 2 - 3, -1)
42+
eq(__LOC__, 2 * 3, 6)
43+
eq(__LOC__, 2 / 3, 0)
44+
})
45+
})

jscomp/test/belt_mapint_ntest.js

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

jscomp/test/belt_mapint_ntest.res

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@@config({flags: ["-bs-no-cross-module-opt"]})
2+
3+
open NodeTest
4+
5+
let ok = (loc, a) => Assert.ok(a, ~message=loc)
6+
7+
module M = Belt.Map.Int
8+
9+
describe("Belt.Map.Int", () => {
10+
test("set", () => {
11+
let m = ref(M.empty)
12+
let count = 100_0000 - 1
13+
14+
for i in 0 to count {
15+
m := M.set(m.contents, i, i)
16+
}
17+
for i in 0 to count {
18+
ok(__LOC__, M.get(m.contents, i) != None)
19+
}
20+
for i in 0 to count {
21+
m := M.remove(m.contents, i)
22+
}
23+
24+
ok(__LOC__, M.isEmpty(m.contents))
25+
})
26+
})

jscomp/test/bs_MapInt_test.js

-35
This file was deleted.

jscomp/test/bs_MapInt_test.res

-23
This file was deleted.

0 commit comments

Comments
 (0)