Skip to content

Start using node test runner instead of mocha #6956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jscomp/test/Assert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions jscomp/test/Assert.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@module("node:assert") external ok: (bool, ~message: string=?) => unit = "ok"
@module("node:assert") external equal: ('a, 'a, ~message: string=?) => unit = "strictEqual"
@module("node:assert") external deepEqual: ('a, 'a, ~message: string=?) => unit = "deepStrictEqual"
@module("node:assert")
external notDeepEqual: ('a, 'a, ~message: string=?) => unit = "notDeepStrictEqual"
@module("node:assert") external fail: (~message: string=?) => unit = "fail"
2 changes: 2 additions & 0 deletions jscomp/test/NodeTest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions jscomp/test/NodeTest.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@module("node:test")
external test: (string, unit => unit) => unit = "test"

@module("node:test")
external describe: (string, unit => unit) => unit = "describe"
51 changes: 51 additions & 0 deletions jscomp/test/belt_float_ntest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions jscomp/test/belt_float_ntest.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
open NodeTest

module F = Belt.Float

let eq = (loc, a, b) => Assert.equal(a, b, ~message=loc)

describe("Belt.Float", () => {
test("fromInt", () => {
eq(__LOC__, F.fromInt(1), 1.0)
eq(__LOC__, F.fromInt(-1), -1.0)
})

test("toInt", () => {
eq(__LOC__, F.toInt(1.0), 1)
eq(__LOC__, F.toInt(1.3), 1)
eq(__LOC__, F.toInt(1.7), 1)
eq(__LOC__, F.toInt(-1.0), -1)
eq(__LOC__, F.toInt(-1.5), -1)
eq(__LOC__, F.toInt(-1.7), -1)
})

test("fromString", () => {
eq(__LOC__, F.fromString("1"), Some(1.0))
eq(__LOC__, F.fromString("-1"), Some(-1.0))
eq(__LOC__, F.fromString("1.7"), Some(1.7))
eq(__LOC__, F.fromString("-1.0"), Some(-1.0))
eq(__LOC__, F.fromString("-1.5"), Some(-1.5))
eq(__LOC__, F.fromString("-1.7"), Some(-1.7))
eq(__LOC__, F.fromString("not a float"), None)
})

test("toString", () => {
eq(__LOC__, F.toString(1.0), "1")
eq(__LOC__, F.toString(-1.0), "-1")
eq(__LOC__, F.toString(-1.5), "-1.5")
})

test("operators", () => {
open! F
eq(__LOC__, 2.0 + 3.0, 5.0)
eq(__LOC__, 2.0 - 3.0, -1.0)
eq(__LOC__, 2.0 * 3.0, 6.0)
eq(__LOC__, 3.0 / 2.0, 1.5)
})
})
50 changes: 50 additions & 0 deletions jscomp/test/belt_int_ntest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions jscomp/test/belt_int_ntest.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
open NodeTest

module I = Belt.Int

let eq = (loc, a, b) => Assert.equal(a, b, ~message=loc)

describe("Belt.Int", () => {
test("toFloat", () => {
eq(__LOC__, I.toFloat(1), 1.0)
eq(__LOC__, I.toFloat(-1), -1.0)
})

test("fromFloat", () => {
eq(__LOC__, I.fromFloat(1.0), 1)
eq(__LOC__, I.fromFloat(1.3), 1)
eq(__LOC__, I.fromFloat(1.7), 1)
eq(__LOC__, I.fromFloat(-1.0), -1)
eq(__LOC__, I.fromFloat(-1.5), -1)
eq(__LOC__, I.fromFloat(-1.7), -1)
})

test("fromString", () => {
eq(__LOC__, I.fromString("1"), Some(1))
eq(__LOC__, I.fromString("-1"), Some(-1))
eq(__LOC__, I.fromString("1.7"), Some(1))
eq(__LOC__, I.fromString("-1.0"), Some(-1))
eq(__LOC__, I.fromString("-1.5"), Some(-1))
eq(__LOC__, I.fromString("-1.7"), Some(-1))
eq(__LOC__, I.fromString("not an int"), None)
})

test("toString", () => {
eq(__LOC__, I.toString(1), "1")
eq(__LOC__, I.toString(-1), "-1")
})

test("operators", () => {
open! I

eq(__LOC__, 2 + 3, 5)
eq(__LOC__, 2 - 3, -1)
eq(__LOC__, 2 * 3, 6)
eq(__LOC__, 2 / 3, 0)
})
})
32 changes: 32 additions & 0 deletions jscomp/test/belt_mapint_ntest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions jscomp/test/belt_mapint_ntest.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@@config({flags: ["-bs-no-cross-module-opt"]})

open NodeTest

let ok = (loc, a) => Assert.ok(a, ~message=loc)

module M = Belt.Map.Int

describe("Belt.Map.Int", () => {
test("set", () => {
let m = ref(M.empty)
let count = 100_0000 - 1

for i in 0 to count {
m := M.set(m.contents, i, i)
}
for i in 0 to count {
ok(__LOC__, M.get(m.contents, i) != None)
}
for i in 0 to count {
m := M.remove(m.contents, i)
}

ok(__LOC__, M.isEmpty(m.contents))
})
})
35 changes: 0 additions & 35 deletions jscomp/test/bs_MapInt_test.js

This file was deleted.

23 changes: 0 additions & 23 deletions jscomp/test/bs_MapInt_test.res

This file was deleted.

Loading
Loading