diff --git a/scripts/res/GenApiDocs.res b/scripts/res/GenApiDocs.res index bf72d64cdf6..477f61f588a 100644 --- a/scripts/res/GenApiDocs.res +++ b/scripts/res/GenApiDocs.res @@ -46,8 +46,6 @@ type section = { submodules: array, } -let env = Process.env - let docsDecoded = entryPointFiles->Array.map(((packageName, libFile)) => try { let entryPointFile = Path.join([ diff --git a/tests/belt_tests/src/belt_list_test.mjs b/tests/belt_tests/src/belt_list_test.mjs index e2ac66043aa..a4ce65569cb 100644 --- a/tests/belt_tests/src/belt_list_test.mjs +++ b/tests/belt_tests/src/belt_list_test.mjs @@ -770,7 +770,7 @@ Mocha.describe("Belt_list_test", () => { Test_utils.eq("File \"belt_list_test.res\", line 147, characters 7-14", Belt_List.take(length_10_id, 0), /* [] */0); Test_utils.eq("File \"belt_list_test.res\", line 148, characters 7-14", Belt_List.take(length_8_id, -2), undefined); }); - Mocha.test("droo", () => { + Mocha.test("drop", () => { Test_utils.eq("File \"belt_list_test.res\", line 152, characters 7-14", Belt_List.drop(length_10_id, 10), /* [] */0); Test_utils.eq("File \"belt_list_test.res\", line 153, characters 7-14", Belt_List.drop(length_10_id, 8), { hd: 8, @@ -1962,7 +1962,7 @@ Mocha.describe("Belt_list_test", () => { } }) === 0); }); - Mocha.test("makeBy", () => { + Mocha.test("make equals makeBy", () => { let makeTest = n => Test_utils.eq("File \"belt_list_test.res\", line 329, characters 27-34", Belt_List.make(n, 3), Belt_List.makeBy(n, param => 3)); makeTest(0); makeTest(1); diff --git a/tests/belt_tests/src/belt_list_test.res b/tests/belt_tests/src/belt_list_test.res index 9f84baa3dfd..8367232b892 100644 --- a/tests/belt_tests/src/belt_list_test.res +++ b/tests/belt_tests/src/belt_list_test.res @@ -148,7 +148,7 @@ describe(__MODULE__, () => { eq(__LOC__, N.take(length_8_id, -2), None) }) - test("droo", () => { + test("drop", () => { eq(__LOC__, N.drop(length_10_id, 10), Some(list{})) eq(__LOC__, N.drop(length_10_id, 8), Some(list{8, 9})) eq(__LOC__, N.drop(length_10_id, 0), Some(length_10_id)) @@ -325,7 +325,7 @@ describe(__MODULE__, () => { ok(__LOC__, N.cmpByLength(list{1, 3}, list{1, 2}) == 0) }) - test("makeBy", () => { + test("make equals makeBy", () => { let makeTest = n => eq(__LOC__, N.make(n, 3), N.makeBy(n, _ => 3)) makeTest(0) diff --git a/tests/belt_tests/src/bs_map_set_dict_test.res b/tests/belt_tests/src/bs_map_set_dict_test.res index d2aa135c4d9..07a105b02a3 100644 --- a/tests/belt_tests/src/bs_map_set_dict_test.res +++ b/tests/belt_tests/src/bs_map_set_dict_test.res @@ -94,7 +94,7 @@ describe(__MODULE__, () => { }) test("map_set_dict_tests", () => { - // All tests are already run as standalone assertions above + // The top-level blocks above only log their results ok(__LOC__, true) }) }) diff --git a/tests/belt_tests/src/list_test.res b/tests/belt_tests/src/list_test.res index 06df039e4ff..6c13149084c 100644 --- a/tests/belt_tests/src/list_test.res +++ b/tests/belt_tests/src/list_test.res @@ -10,7 +10,7 @@ describe(__MODULE__, () => { }) test("length2", () => { - eq(__LOC__, 5, List.length(list{0, 1, 2, 3, 4})) /* This is tuple haha */ + eq(__LOC__, 5, List.length(list{0, 1, 2, 3, 4})) }) test("long_length", () => { diff --git a/tests/belt_tests/src/test_for_map.mjs b/tests/belt_tests/src/test_for_map.mjs deleted file mode 100644 index b14e15e2e1e..00000000000 --- a/tests/belt_tests/src/test_for_map.mjs +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Belt_MapInt from "@rescript/belt/lib/es6/src/Belt_MapInt.mjs"; - -function assertion_test() { - let m; - for (let i = 0; i <= 1000000; ++i) { - m = Belt_MapInt.set(m, i, i); - } - for (let i$1 = 0; i$1 <= 1000000; ++i$1) { - Belt_MapInt.get(m, i$1); - } -} - -let IntMap; - -export { - IntMap, - assertion_test, -} -/* No side effect */ diff --git a/tests/belt_tests/src/test_for_map.res b/tests/belt_tests/src/test_for_map.res deleted file mode 100644 index 3af916caf93..00000000000 --- a/tests/belt_tests/src/test_for_map.res +++ /dev/null @@ -1,12 +0,0 @@ -module IntMap = Belt.Map.Int - -let assertion_test = () => { - let m = ref(IntMap.empty) - let count = 1000000 - for i in 0 to count { - m := m.contents->IntMap.set(i, i) - } - for i in 0 to count { - m.contents->IntMap.get(i)->ignore - } -} diff --git a/tests/belt_tests/src/test_utils.mjs b/tests/belt_tests/src/test_utils.mjs index 8dbe369ec5c..6d3ed30222d 100644 --- a/tests/belt_tests/src/test_utils.mjs +++ b/tests/belt_tests/src/test_utils.mjs @@ -14,15 +14,9 @@ function throws(loc, f) { Nodeassert.throws(f, undefined, loc); } -function approxEq(loc, threshold, a, b) { - let diff = Math.abs(a - b); - Nodeassert.ok(diff <= threshold, loc); -} - export { ok, eq, throws, - approxEq, } /* node:assert Not a pure module */ diff --git a/tests/belt_tests/src/test_utils.res b/tests/belt_tests/src/test_utils.res index a713650a8f8..119cefc04c2 100644 --- a/tests/belt_tests/src/test_utils.res +++ b/tests/belt_tests/src/test_utils.res @@ -1,8 +1,3 @@ let ok = (loc, a) => Node_assert.ok(a, ~message=loc) let eq = (loc, a, b) => Node_assert.deepEqual(a, b, ~message=loc) let throws = (loc, f) => Node_assert.throws(f, ~message=loc) - -let approxEq = (loc, threshold, a, b) => { - let diff = Math.abs(a -. b) - Node_assert.ok(diff <= threshold, ~message=loc) -} diff --git a/tests/belt_tests/src/ticker.res b/tests/belt_tests/src/ticker.res index 681004fa370..b462b74ddbd 100644 --- a/tests/belt_tests/src/ticker.res +++ b/tests/belt_tests/src/ticker.res @@ -95,7 +95,7 @@ module Ticker_map = Map.String algorithm (lowest rank for the deepest nodes). We then collect all the tickers which depends on each of the - market tickers and finally we `sort_uniq` that list by rank to + market tickers and finally we sort that list by rank to guarantee that a composite ticker is update only once and in the correct order. */ diff --git a/tests/docstring_tests/Node.res b/tests/docstring_tests/Node.res index bcdd75c2b4e..29783b629a0 100644 --- a/tests/docstring_tests/Node.res +++ b/tests/docstring_tests/Node.res @@ -1,20 +1,16 @@ module Path = { - @module("node:path") external join2: (string, string) => string = "join" @module("node:path") @variadic external join: array => string = "join" @module("node:path") external dirname: string => string = "dirname" } module Process = { - @scope("process") external cwd: unit => string = "cwd" @scope("process") @val external version: string = "version" - @scope("process") @val external argv: array = "argv" - @scope("process") external exit: int => unit = "exit" - @scope("process") external env: Dict.t = "env" } module Fs = { @module("node:fs") external readdirSync: string => array = "readdirSync" @module("node:fs/promises") external writeFile: (string, string) => promise = "writeFile" + // existsSync, mkdirSync, writeFileSync and readFileSync are used by scripts/res/GenApiDocs.res @module("node:fs") external existsSync: string => bool = "existsSync" @module("node:fs") external mkdirSync: string => unit = "mkdirSync" @module("node:fs") external writeFileSync: (string, string) => unit = "writeFileSync" @@ -36,6 +32,7 @@ module ChildProcess = { @send external on: (readable, string, Buffer.t => unit) => unit = "on" @send external once: (spawnReturns, string, (Null.t, Null.t) => unit) => unit = "once" + // execSync is used by scripts/res/GenApiDocs.res type execSyncOptions = {maxBuffer?: float} @module("child_process") external execSync: (string, ~options: execSyncOptions=?) => Buffer.t = "execSync" @@ -51,4 +48,5 @@ module URL = { } @val @scope(("import", "meta")) external url: string = "url" +// dirname is used by scripts/res/GenApiDocs.res @val @scope(("import", "meta")) external dirname: string = "dirname" diff --git a/tests/tests/src/DerivingAccessorsUncurried.mjs b/tests/tests/src/DerivingAccessorsUncurried.mjs deleted file mode 100644 index a816cc5575a..00000000000 --- a/tests/tests/src/DerivingAccessorsUncurried.mjs +++ /dev/null @@ -1,57 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -function myField(param) { - return param.myField; -} - -function num(param_0) { - return { - TAG: "Num", - _0: param_0 - }; -} - -function doubleNum(param_0, param_1) { - return { - TAG: "DoubleNum", - _0: param_0, - _1: param_1 - }; -} - -function compose(a, accessor) { - return accessor(a); -} - -let _composedMyField = 1; - -let _composedNum = { - TAG: "Num", - _0: 1 -}; - -let noParam = "NoParam"; - -let _myFieldAlias = myField; - -let _noParamAlias = "NoParam"; - -let _numAlias = num; - -let _doubleNumAlias = doubleNum; - -export { - myField, - noParam, - num, - doubleNum, - _myFieldAlias, - _noParamAlias, - _numAlias, - _doubleNumAlias, - compose, - _composedMyField, - _composedNum, -} -/* No side effect */ diff --git a/tests/tests/src/DerivingAccessorsUncurried.res b/tests/tests/src/DerivingAccessorsUncurried.res deleted file mode 100644 index b80b5b1b3e3..00000000000 --- a/tests/tests/src/DerivingAccessorsUncurried.res +++ /dev/null @@ -1,21 +0,0 @@ -//Assert that deriving accessors does not break -//In uncurried mode -@@uncurried - -@deriving(accessors) -type myRecord = {myField: int} - -@deriving(accessors) -type variant = NoParam | Num(int) | DoubleNum(int, int) - -//Asserts the correct signature for derived accessor -let _myFieldAlias: myRecord => int = myField -let _noParamAlias: variant = noParam -let _numAlias: int => variant = num -let _doubleNumAlias: (int, int) => variant = doubleNum - -//Asserts that inference works when composing -//with derived functions -let compose = (a, accessor) => accessor(a) -let _composedMyField = compose({myField: 1}, myField) -let _composedNum = compose(1, num) diff --git a/tests/tests/src/DotDotDot.res b/tests/tests/src/DotDotDot.res index 0a0cf79e94d..febc517bb85 100644 --- a/tests/tests/src/DotDotDot.res +++ b/tests/tests/src/DotDotDot.res @@ -37,9 +37,6 @@ type svgProps = { let x: svgProps = {x: "test", name: "test"} -// uncomment this to reveal a parser error -// type copiedSvgProps = {...svgProps} - module MultipleDotDotDots = { type t1 = {x: int} type t2 = {y: string} diff --git a/tests/tests/src/a_scope_bug.res b/tests/tests/src/a_scope_bug.res index 9a7faff9db3..d683578f27e 100644 --- a/tests/tests/src/a_scope_bug.res +++ b/tests/tests/src/a_scope_bug.res @@ -1,6 +1,3 @@ -/** FIXME: the inner - [even ] is printed as [even] while global [even] is printed as [even$1] -*/ let rec odd = z => { let a = { let even = z diff --git a/tests/tests/src/arity_deopt.mjs b/tests/tests/src/arity_deopt_test.mjs similarity index 55% rename from tests/tests/src/arity_deopt.mjs rename to tests/tests/src/arity_deopt_test.mjs index 7d5964fc77d..ca0d033b470 100644 --- a/tests/tests/src/arity_deopt.mjs +++ b/tests/tests/src/arity_deopt_test.mjs @@ -19,12 +19,12 @@ function f3(x) { return (y, z) => (x + y | 0) + z | 0; } -Mocha.describe("Arity_deopt", () => { +Mocha.describe("Arity_deopt_test", () => { Mocha.test("arity_deopt_tests", () => { - Test_utils.eq("File \"arity_deopt.res\", line 43, characters 7-14", 6, 6); - Test_utils.eq("File \"arity_deopt.res\", line 44, characters 7-14", 6, 6); - Test_utils.eq("File \"arity_deopt.res\", line 45, characters 7-14", 6, 6); - Test_utils.eq("File \"arity_deopt.res\", line 46, characters 7-14", 6, 6); + Test_utils.eq("File \"arity_deopt_test.res\", line 43, characters 7-14", 6, 6); + Test_utils.eq("File \"arity_deopt_test.res\", line 44, characters 7-14", 6, 6); + Test_utils.eq("File \"arity_deopt_test.res\", line 45, characters 7-14", 6, 6); + Test_utils.eq("File \"arity_deopt_test.res\", line 46, characters 7-14", 6, 6); }); }); diff --git a/tests/tests/src/arity_deopt.res b/tests/tests/src/arity_deopt_test.res similarity index 100% rename from tests/tests/src/arity_deopt.res rename to tests/tests/src/arity_deopt_test.res diff --git a/tests/tests/src/bs_auto_uncurry.res b/tests/tests/src/bs_auto_uncurry.res index 673049bcf99..507e03087e6 100644 --- a/tests/tests/src/bs_auto_uncurry.res +++ b/tests/tests/src/bs_auto_uncurry.res @@ -46,7 +46,6 @@ let f_02 = xs => Console.log("x") }) let f_03 = (xs, u) => hi(u) -/* arity adjust to [0] [ function (){return u (0)}] */ let h = (x, y, z) => map2(x, y, z) diff --git a/tests/tests/src/bs_ignore_effect.mjs b/tests/tests/src/bs_ignore_effect_test.mjs similarity index 73% rename from tests/tests/src/bs_ignore_effect.mjs rename to tests/tests/src/bs_ignore_effect_test.mjs index d2e755cc724..fc56b964304 100644 --- a/tests/tests/src/bs_ignore_effect.mjs +++ b/tests/tests/src/bs_ignore_effect_test.mjs @@ -19,9 +19,9 @@ let h = (v.contents = v.contents + 1 | 0, { let z = (v.contents = v.contents + 1 | 0, "Float", add(3.0, 2.0)); -Mocha.describe("Bs_ignore_effect", () => { - Mocha.test("ignore effect 1", () => Test_utils.eq("File \"bs_ignore_effect.res\", line 29, characters 35-42", v.contents, 2)); - Mocha.test("ignore effect 2", () => Test_utils.eq("File \"bs_ignore_effect.res\", line 30, characters 35-42", z, 5.0)); +Mocha.describe("Bs_ignore_effect_test", () => { + Mocha.test("ignore effect 1", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 29, characters 35-42", v.contents, 2)); + Mocha.test("ignore effect 2", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 30, characters 35-42", z, 5.0)); }); export { diff --git a/tests/tests/src/bs_ignore_effect.res b/tests/tests/src/bs_ignore_effect_test.res similarity index 100% rename from tests/tests/src/bs_ignore_effect.res rename to tests/tests/src/bs_ignore_effect_test.res diff --git a/tests/tests/src/test_case_opt_collision.mjs b/tests/tests/src/case_opt_collision_test.mjs similarity index 73% rename from tests/tests/src/test_case_opt_collision.mjs rename to tests/tests/src/case_opt_collision_test.mjs index 596e3320618..61395c67a76 100644 --- a/tests/tests/src/test_case_opt_collision.mjs +++ b/tests/tests/src/case_opt_collision_test.mjs @@ -10,11 +10,11 @@ function f(xOpt, y) { return xOpt$1 + y | 0; } -Mocha.describe("Test_case_opt_collision", () => { +Mocha.describe("Case_opt_collision_test", () => { Mocha.test("optional parameter collision", () => { console.log(f(undefined, 2)); - Test_utils.eq("File \"test_case_opt_collision.res\", line 13, characters 7-14", f(undefined, 2), 7); - Test_utils.eq("File \"test_case_opt_collision.res\", line 14, characters 7-14", f(4, 2), 8); + Test_utils.eq("File \"case_opt_collision_test.res\", line 13, characters 7-14", f(undefined, 2), 7); + Test_utils.eq("File \"case_opt_collision_test.res\", line 14, characters 7-14", f(4, 2), 8); }); }); diff --git a/tests/tests/src/test_case_opt_collision.res b/tests/tests/src/case_opt_collision_test.res similarity index 100% rename from tests/tests/src/test_case_opt_collision.res rename to tests/tests/src/case_opt_collision_test.res diff --git a/tests/tests/src/conditional/cond_a_C.mjs b/tests/tests/src/conditional/cond_a_C.mjs deleted file mode 100644 index 50cff7a715f..00000000000 --- a/tests/tests/src/conditional/cond_a_C.mjs +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -let C = { - value: 3 -}; - -let A = { - u: 3 -}; - -export { - C, - A, -} -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_a_C.res b/tests/tests/src/conditional/cond_a_C.res deleted file mode 100644 index fe61d4890de..00000000000 --- a/tests/tests/src/conditional/cond_a_C.res +++ /dev/null @@ -1,6 +0,0 @@ -module C = { - let value = 3 -} -module A = { - let u = C.value -} diff --git a/tests/tests/src/conditional/cond_c.mjs b/tests/tests/src/conditional/cond_c.mjs deleted file mode 100644 index 522d8f92129..00000000000 --- a/tests/tests/src/conditional/cond_c.mjs +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -let value = 3; - -export { - value, -} -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_c.res b/tests/tests/src/conditional/cond_c.res deleted file mode 100644 index e1b898c1881..00000000000 --- a/tests/tests/src/conditional/cond_c.res +++ /dev/null @@ -1 +0,0 @@ -let value = 3 diff --git a/tests/tests/src/debug_tmp.mjs b/tests/tests/src/debug_tmp.mjs deleted file mode 100644 index d856702bfe6..00000000000 --- a/tests/tests/src/debug_tmp.mjs +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/tests/tests/src/debug_tmp.res b/tests/tests/src/debug_tmp.res deleted file mode 100644 index 950ffcf04c6..00000000000 --- a/tests/tests/src/debug_tmp.res +++ /dev/null @@ -1,21 +0,0 @@ -@@config({ - flags: [ - "-w", - "@A", - /* "-drawlambda"; */ - /* "-dtypedtree"; */ - /* "-dparsetree"; */ - /* "-dsource"; */ - /* "-bs-no-builtin-ppx"; */ - ], -}) -/* -let h1 = fun [@bs]() -> 1 -let h0 f a b c = f a b c [@bs] -let h = -let f x ~y = x + y in - f ~y:3 */ - -/* let f x ~y = x + y - -;; Console.log (f 2 3) */ diff --git a/tests/tests/src/flexible_array_test.mjs b/tests/tests/src/flexible_array_test.mjs index 5f346368a24..5ee6828a637 100644 --- a/tests/tests/src/flexible_array_test.mjs +++ b/tests/tests/src/flexible_array_test.mjs @@ -315,7 +315,17 @@ let x$1 = sort(of_array(v)); let y = Stdlib_Array.fromInitializer(500, i => i + 1 | 0); -Primitive_object.equal(x$1, of_array(y)); +if (!Primitive_object.equal(x$1, of_array(y))) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "flexible_array_test.res", + 187, + 2 + ], + Error: new Error() + }; +} export { sub, diff --git a/tests/tests/src/flexible_array_test.res b/tests/tests/src/flexible_array_test.res index 17fc07b69cb..a54df1f9724 100644 --- a/tests/tests/src/flexible_array_test.res +++ b/tests/tests/src/flexible_array_test.res @@ -184,5 +184,8 @@ let _ = { assert(\"=~"(Int_array.sort(u), [1, 2, 2, 3, 5, 6])) let len = 500 let v = Array.fromInitializer(~length=len, i => len - i) - \"=~"(Int_array.sort(Int_array.of_array(v)), Array.fromInitializer(~length=len, i => i + 1)) + assert(\"=~"( + Int_array.sort(Int_array.of_array(v)), + Array.fromInitializer(~length=len, i => i + 1), + )) } diff --git a/tests/tests/src/float_test.mjs b/tests/tests/src/float_test.mjs index 20d05b1cdba..d02bf02aece 100644 --- a/tests/tests/src/float_test.mjs +++ b/tests/tests/src/float_test.mjs @@ -111,9 +111,9 @@ Mocha.describe("Float_test", () => { Test_utils.eq("File \"float_test.res\", line 70, characters 7-14", Primitive_object.greaterthan(nan, 4.2), false); Test_utils.eq("File \"float_test.res\", line 71, characters 7-14", nan <= nan, false); Test_utils.eq("File \"float_test.res\", line 72, characters 7-14", Primitive_object.lessequal(nan, nan), false); - Test_utils.eq("File \"float_test.res\", line 73, characters 7-14", Primitive_object.lessequal(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 73, characters 7-14", 4.2 <= nan, false); Test_utils.eq("File \"float_test.res\", line 74, characters 7-14", Primitive_object.lessequal(4.2, nan), false); - Test_utils.eq("File \"float_test.res\", line 75, characters 7-14", Primitive_object.lessequal(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 75, characters 7-14", nan <= 4.2, false); Test_utils.eq("File \"float_test.res\", line 76, characters 7-14", Primitive_object.lessequal(nan, 4.2), false); Test_utils.eq("File \"float_test.res\", line 77, characters 7-14", nan >= nan, false); Test_utils.eq("File \"float_test.res\", line 78, characters 7-14", Primitive_object.greaterequal(nan, nan), false); diff --git a/tests/tests/src/float_test.res b/tests/tests/src/float_test.res index a0618c51eb7..0a11afd1df5 100644 --- a/tests/tests/src/float_test.res +++ b/tests/tests/src/float_test.res @@ -70,9 +70,9 @@ describe(__MODULE__, () => { eq(__LOC__, generic_greaterthan(nan, 4.2), false) eq(__LOC__, float_lessequal(nan, nan), false) eq(__LOC__, generic_lessequal(nan, nan), false) + eq(__LOC__, float_lessequal(4.2, nan), false) eq(__LOC__, generic_lessequal(4.2, nan), false) - eq(__LOC__, generic_lessequal(4.2, nan), false) - eq(__LOC__, generic_lessequal(nan, 4.2), false) + eq(__LOC__, float_lessequal(nan, 4.2), false) eq(__LOC__, generic_lessequal(nan, 4.2), false) eq(__LOC__, float_greaterequal(nan, nan), false) eq(__LOC__, generic_greaterequal(nan, nan), false) diff --git a/tests/tests/src/test_for_of.mjs b/tests/tests/src/for_of_test.mjs similarity index 86% rename from tests/tests/src/test_for_of.mjs rename to tests/tests/src/for_of_test.mjs index f9707126aff..8fcbe9902d1 100644 --- a/tests/tests/src/test_for_of.mjs +++ b/tests/tests/src/for_of_test.mjs @@ -31,7 +31,7 @@ function countItems(arr) { return count; } -Mocha.describe("Test_for_of", () => { +Mocha.describe("For_of_test", () => { Mocha.test("basic iteration", () => { let arr = [ 1, @@ -44,7 +44,7 @@ Mocha.describe("Test_for_of", () => { for (let x of arr) { sum = sum + x | 0; } - Test_utils.eq("File \"test_for_of.res\", line 44, characters 7-14", sum, 15); + Test_utils.eq("File \"for_of_test.res\", line 44, characters 7-14", sum, 15); }); Mocha.test("single element", () => { let arr = [42]; @@ -52,15 +52,15 @@ Mocha.describe("Test_for_of", () => { for (let x of arr) { result = x; } - Test_utils.eq("File \"test_for_of.res\", line 55, characters 7-14", result, 42); + Test_utils.eq("File \"for_of_test.res\", line 55, characters 7-14", result, 42); }); Mocha.test("empty array", () => { let arr = []; for (let _for_of of arr) { - Test_utils.ok("File \"test_for_of.res\", line 63, characters 9-16", false); + Test_utils.ok("File \"for_of_test.res\", line 63, characters 9-16", false); } }); - Mocha.test("unused named loop variable", () => Test_utils.eq("File \"test_for_of.res\", line 68, characters 7-14", countItems([ + Mocha.test("unused named loop variable", () => Test_utils.eq("File \"for_of_test.res\", line 68, characters 7-14", countItems([ 1, 2, 3 @@ -76,7 +76,7 @@ Mocha.describe("Test_for_of", () => { let x$1 = x + 10 | 0; sum = sum + x$1 | 0; } - Test_utils.eq("File \"test_for_of.res\", line 80, characters 7-14", sum, 36); + Test_utils.eq("File \"for_of_test.res\", line 80, characters 7-14", sum, 36); }); Mocha.test("break and continue target the for..of loop from nested switches", () => { let arr = [ @@ -99,7 +99,7 @@ Mocha.describe("Test_for_of", () => { ]); } } - Test_utils.eq("File \"test_for_of.res\", line 95, characters 7-14", seen, [2]); + Test_utils.eq("File \"for_of_test.res\", line 95, characters 7-14", seen, [2]); }); Mocha.test("blog-style order scan uses continue and break", () => { let orders = [ @@ -129,7 +129,7 @@ Mocha.describe("Test_for_of", () => { total: 900 } ]; - Test_utils.eq("File \"test_for_of.res\", line 107, characters 7-14", firstLargeOpenOrder(orders), 104); + Test_utils.eq("File \"for_of_test.res\", line 107, characters 7-14", firstLargeOpenOrder(orders), 104); }); }); diff --git a/tests/tests/src/test_for_of.res b/tests/tests/src/for_of_test.res similarity index 100% rename from tests/tests/src/test_for_of.res rename to tests/tests/src/for_of_test.res diff --git a/tests/tests/src/gpr_1759_test.mjs b/tests/tests/src/gpr_1759_test.mjs deleted file mode 100644 index d856702bfe6..00000000000 --- a/tests/tests/src/gpr_1759_test.mjs +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/tests/tests/src/gpr_1759_test.res b/tests/tests/src/gpr_1759_test.res deleted file mode 100644 index 8e6e2fd9df0..00000000000 --- a/tests/tests/src/gpr_1759_test.res +++ /dev/null @@ -1,6 +0,0 @@ -/* ;; let i:int = - (compare (print_string "") ()) - in print_int i - -;; print_string -(if (<>) () (print_string "") then "true" else "false") */ diff --git a/tests/tests/src/gpr_2789_test.mjs b/tests/tests/src/gpr_2789_test.mjs deleted file mode 100644 index 6060465b159..00000000000 --- a/tests/tests/src/gpr_2789_test.mjs +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Gpr_2789_test", () => { - Mocha.test("weak array commented out tests", () => Test_utils.eq("File \"gpr_2789_test.res\", line 7, characters 7-14", 1, 1)); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_2789_test.res b/tests/tests/src/gpr_2789_test.res deleted file mode 100644 index ad3f063a2f8..00000000000 --- a/tests/tests/src/gpr_2789_test.res +++ /dev/null @@ -1,9 +0,0 @@ -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("weak array commented out tests", () => { - // Tests are commented out, just verify compilation - eq(__LOC__, 1, 1) - }) -}) diff --git a/tests/tests/src/gpr_441.mjs b/tests/tests/src/gpr_441.mjs deleted file mode 100644 index d856702bfe6..00000000000 --- a/tests/tests/src/gpr_441.mjs +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/tests/tests/src/gpr_441.res b/tests/tests/src/gpr_441.res deleted file mode 100644 index 7c33000321a..00000000000 --- a/tests/tests/src/gpr_441.res +++ /dev/null @@ -1,4 +0,0 @@ -/* external new_rectangle : */ -/* unit -> int = "" [@@new] [@@module "@Rectangle"] */ - -/* let rect = new_rectangle */ diff --git a/tests/tests/src/gpr_4494_test.mjs b/tests/tests/src/gpr_4494_test.mjs deleted file mode 100644 index d856702bfe6..00000000000 --- a/tests/tests/src/gpr_4494_test.mjs +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/tests/tests/src/gpr_4494_test.res b/tests/tests/src/gpr_4494_test.res deleted file mode 100644 index 97fb80dbfff..00000000000 --- a/tests/tests/src/gpr_4494_test.res +++ /dev/null @@ -1 +0,0 @@ -/* disable it temporarily since it's TNTE */ diff --git a/tests/tests/src/inline_map_demo.mjs b/tests/tests/src/inline_map_demo_test.mjs similarity index 92% rename from tests/tests/src/inline_map_demo.mjs rename to tests/tests/src/inline_map_demo_test.mjs index 17790a7b1db..e65a00890a6 100644 --- a/tests/tests/src/inline_map_demo.mjs +++ b/tests/tests/src/inline_map_demo_test.mjs @@ -36,7 +36,7 @@ function bal(l, x, d, r) { throw { RE_EXN_ID: "Assert_failure", _1: [ - "inline_map_demo.res", + "inline_map_demo_test.res", 41, 15 ], @@ -56,7 +56,7 @@ function bal(l, x, d, r) { throw { RE_EXN_ID: "Assert_failure", _1: [ - "inline_map_demo.res", + "inline_map_demo_test.res", 47, 19 ], @@ -77,7 +77,7 @@ function bal(l, x, d, r) { throw { RE_EXN_ID: "Assert_failure", _1: [ - "inline_map_demo.res", + "inline_map_demo_test.res", 55, 15 ], @@ -97,7 +97,7 @@ function bal(l, x, d, r) { throw { RE_EXN_ID: "Assert_failure", _1: [ - "inline_map_demo.res", + "inline_map_demo_test.res", 61, 19 ], @@ -181,8 +181,8 @@ function find(px, _x) { }; } -Mocha.describe("Inline_map_demo", () => { - Mocha.test("find", () => Test_utils.eq("File \"inline_map_demo.res\", line 141, characters 24-31", find(10, m), /* 'a' */97)); +Mocha.describe("Inline_map_demo_test", () => { + Mocha.test("find", () => Test_utils.eq("File \"inline_map_demo_test.res\", line 141, characters 24-31", find(10, m), /* 'a' */97)); }); /* m Not a pure module */ diff --git a/tests/tests/src/inline_map_demo.res b/tests/tests/src/inline_map_demo_test.res similarity index 100% rename from tests/tests/src/inline_map_demo.res rename to tests/tests/src/inline_map_demo_test.res diff --git a/tests/tests/src/int_overflow_test.res b/tests/tests/src/int_overflow_test.res index bd013a3ed1c..542c7dcd91a 100644 --- a/tests/tests/src/int_overflow_test.res +++ b/tests/tests/src/int_overflow_test.res @@ -3,8 +3,8 @@ open Test_utils @@warning("-107") -let max_int = 2147483647 // 0x80000000 -let min_int = -2147483648 // 0x7FFFFFFF +let max_int = 2147483647 // 0x7FFFFFFF +let min_int = -2147483648 // 0x80000000 let hash_variant = s => { let accu = ref(0) diff --git a/tests/tests/src/int_poly_var.mjs b/tests/tests/src/int_poly_var_test.mjs similarity index 90% rename from tests/tests/src/int_poly_var.mjs rename to tests/tests/src/int_poly_var_test.mjs index 46de8352006..e8be67c412a 100644 --- a/tests/tests/src/int_poly_var.mjs +++ b/tests/tests/src/int_poly_var_test.mjs @@ -143,10 +143,10 @@ function f(x) { } } -Mocha.describe("Int_poly_var", () => { +Mocha.describe("Int_poly_var_test", () => { Mocha.test("int poly var test", () => { - Test_utils.eq("File \"int_poly_var.res\", line 102, characters 7-14", hihi, 3); - Test_utils.eq("File \"int_poly_var.res\", line 103, characters 7-14", tuple, [ + Test_utils.eq("File \"int_poly_var_test.res\", line 102, characters 7-14", hihi, 3); + Test_utils.eq("File \"int_poly_var_test.res\", line 103, characters 7-14", tuple, [ 0, 1, 2, diff --git a/tests/tests/src/int_poly_var.res b/tests/tests/src/int_poly_var_test.res similarity index 100% rename from tests/tests/src/int_poly_var.res rename to tests/tests/src/int_poly_var_test.res diff --git a/tests/tests/src/node_assert.res b/tests/tests/src/node_assert.res index 57e41878351..517fb802898 100644 --- a/tests/tests/src/node_assert.res +++ b/tests/tests/src/node_assert.res @@ -1,8 +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" @module("node:assert") external throws: (unit => 'a, ~error: 'b=?, ~message: string=?) => unit = "throws" diff --git a/tests/tests/src/optional_ffi_test.mjs b/tests/tests/src/optional_ffi_test.mjs index 295aebd62bb..c29f82af0d6 100644 --- a/tests/tests/src/optional_ffi_test.mjs +++ b/tests/tests/src/optional_ffi_test.mjs @@ -69,7 +69,7 @@ Mocha.describe("Optional_ffi_test", () => { let v2 = bug_to_fix2(side_effect2, counter2); let pair2_0 = [ v2, - counter.contents + counter2.contents ]; let pair2_1 = [ 4, diff --git a/tests/tests/src/optional_ffi_test.res b/tests/tests/src/optional_ffi_test.res index 49dc9ca75f4..6a22bb1a680 100644 --- a/tests/tests/src/optional_ffi_test.res +++ b/tests/tests/src/optional_ffi_test.res @@ -43,7 +43,7 @@ describe(__MODULE__, () => { let v = bug_to_fix(side_effect, counter) let pair = ((v, counter.contents), (4, 1)) let v2 = bug_to_fix2(side_effect2, counter2) - let pair2 = ((v2, counter.contents), (4, 1)) + let pair2 = ((v2, counter2.contents), (4, 1)) /* Console.log (pair,pair2) */ eq(__LOC__, pair, ((4, 1), (4, 1))) eq(__LOC__, pair2, ((4, 1), (4, 1))) diff --git a/tests/tests/src/pipe_send_readline.res b/tests/tests/src/pipe_send_readline.res index 9220df88b4c..f58e460005b 100644 --- a/tests/tests/src/pipe_send_readline.res +++ b/tests/tests/src/pipe_send_readline.res @@ -1,5 +1,3 @@ -/* should give a warning on unused attribute.. [@@bs.xx] */ - type readline @send external on: ( diff --git a/tests/tests/src/recursive_module.mjs b/tests/tests/src/recursive_module2_test.mjs similarity index 81% rename from tests/tests/src/recursive_module.mjs rename to tests/tests/src/recursive_module2_test.mjs index 12f04b3970b..77f7edb4e61 100644 --- a/tests/tests/src/recursive_module.mjs +++ b/tests/tests/src/recursive_module2_test.mjs @@ -11,7 +11,7 @@ let Xx = { }; let Int3 = Primitive_module.init([ - "recursive_module.res", + "recursive_module2_test.res", 24, 4 ], { @@ -47,9 +47,9 @@ let A = { Intb: Intb }; -Mocha.describe("Recursive_module", () => { +Mocha.describe("Recursive_module2_test", () => { Mocha.test("recursive module test", () => { - Test_utils.eq("File \"recursive_module.res\", line 41, characters 7-14", Stdlib_Lazy.get(a$1), 3); + Test_utils.eq("File \"recursive_module2_test.res\", line 41, characters 7-14", Stdlib_Lazy.get(a$1), 3); let tmp; try { Int3.u(3); @@ -62,7 +62,7 @@ Mocha.describe("Recursive_module", () => { throw exn; } } - Test_utils.eq("File \"recursive_module.res\", line 44, characters 6-13", 4, tmp); + Test_utils.eq("File \"recursive_module2_test.res\", line 44, characters 6-13", 4, tmp); }); }); diff --git a/tests/tests/src/recursive_module.res b/tests/tests/src/recursive_module2_test.res similarity index 100% rename from tests/tests/src/recursive_module.res rename to tests/tests/src/recursive_module2_test.res diff --git a/tests/tests/src/stdlib/Stdlib_ImportTests.mjs b/tests/tests/src/stdlib/Stdlib_ImportTests.mjs index 729eab18195..56020b06686 100644 --- a/tests/tests/src/stdlib/Stdlib_ImportTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_ImportTests.mjs @@ -15,7 +15,9 @@ async function main() { ], 1, eq, 1); } +main(); + export { main, } -/* Test Not a pure module */ +/* Not a pure module */ diff --git a/tests/tests/src/stdlib/Stdlib_ImportTests.res b/tests/tests/src/stdlib/Stdlib_ImportTests.res index b25f7779eb3..fd5deba3d8a 100644 --- a/tests/tests/src/stdlib/Stdlib_ImportTests.res +++ b/tests/tests/src/stdlib/Stdlib_ImportTests.res @@ -3,4 +3,4 @@ let main = async () => { Test.run(__POS_OF__("dynamic import - Int tests - eq"), 1, eq, 1) } -main->ignore +main()->ignore diff --git a/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs b/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs index fc1a8047702..e8d01aceb1f 100644 --- a/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs +++ b/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs @@ -264,9 +264,9 @@ function testResolveFinally() { "Stdlib_PromiseTest.res", 242, 26, - 45 + 46 ], - "value should be 5" + "value should be 10" ], v, equal, 10); Test.run([ [ diff --git a/tests/tests/src/stdlib/Stdlib_PromiseTest.res b/tests/tests/src/stdlib/Stdlib_PromiseTest.res index 0040daba61d..a5c89de490c 100644 --- a/tests/tests/src/stdlib/Stdlib_PromiseTest.res +++ b/tests/tests/src/stdlib/Stdlib_PromiseTest.res @@ -239,7 +239,7 @@ module Catching = { wasCalled := true }) ->then(v => { - Test.run(__POS_OF__("value should be 5"), v, equal, 10) + Test.run(__POS_OF__("value should be 10"), v, equal, 10) Test.run(__POS_OF__("finally should have been called"), wasCalled.contents, equal, true) resolve() }) diff --git a/tests/tests/src/stdlib/Stdlib_TestSuite.mjs b/tests/tests/src/stdlib/Stdlib_TestSuite.mjs index 1d33e630558..e64d42c6438 100644 --- a/tests/tests/src/stdlib/Stdlib_TestSuite.mjs +++ b/tests/tests/src/stdlib/Stdlib_TestSuite.mjs @@ -9,9 +9,11 @@ import * as Stdlib_ArrayTests from "./Stdlib_ArrayTests.mjs"; import * as Stdlib_ErrorTests from "./Stdlib_ErrorTests.mjs"; import * as Stdlib_FloatTests from "./Stdlib_FloatTests.mjs"; import * as Stdlib_RegExpTest from "./Stdlib_RegExpTest.mjs"; +import * as Stdlib_ImportTests from "./Stdlib_ImportTests.mjs"; import * as Stdlib_ObjectTests from "./Stdlib_ObjectTests.mjs"; import * as Stdlib_PromiseTest from "./Stdlib_PromiseTest.mjs"; import * as Stdlib_ResultTests from "./Stdlib_ResultTests.mjs"; +import * as Stdlib_StringTests from "./Stdlib_StringTests.mjs"; import * as Stdlib_IteratorTests from "./Stdlib_IteratorTests.mjs"; import * as Stdlib_NullableTests from "./Stdlib_NullableTests.mjs"; import * as Stdlib_TypedArrayTests from "./Stdlib_TypedArrayTests.mjs"; @@ -170,7 +172,9 @@ let asyncGeneratorThrowError = Stdlib_IteratorTests.asyncGeneratorThrowError; let createdAsyncIterableIterator = Stdlib_IteratorTests.createdAsyncIterableIterator; -let eq = Stdlib_RegExpTest.eq; +let eq = Stdlib_StringTests.eq; + +let main = Stdlib_ImportTests.main; export { bign, @@ -251,5 +255,6 @@ export { asyncGeneratorThrowError, createdAsyncIterableIterator, eq, + main, } /* Stdlib_IntTests Not a pure module */ diff --git a/tests/tests/src/stdlib/Stdlib_TestSuite.res b/tests/tests/src/stdlib/Stdlib_TestSuite.res index 6ea9e4ed2df..e39543615aa 100644 --- a/tests/tests/src/stdlib/Stdlib_TestSuite.res +++ b/tests/tests/src/stdlib/Stdlib_TestSuite.res @@ -13,3 +13,5 @@ include Stdlib_NullableTests include Stdlib_DictTests include Stdlib_IteratorTests include Stdlib_RegExpTest +include Stdlib_StringTests +include Stdlib_ImportTests diff --git a/tests/tests/src/stdlib/Test.mjs b/tests/tests/src/stdlib/Test.mjs index bcb1b4e0445..c9d7517e67e 100644 --- a/tests/tests/src/stdlib/Test.mjs +++ b/tests/tests/src/stdlib/Test.mjs @@ -46,6 +46,7 @@ ${codeFrame} \u001b[39mRight: \u001b[31m${right$1}\u001b[0m `; console.log(errorMessage); + process.exitCode = 1; let obj = {}; Error.captureStackTrace(obj); console.log(obj.stack.replace(/\n /g, "\n ").replace(/^Error\n/, "").replace(/^.+\n/, "").replace(/\n at .+\(node:internal.+\n?/g, "")); diff --git a/tests/tests/src/stdlib/Test.res b/tests/tests/src/stdlib/Test.res index 6bd7c8659f2..ab6122a6329 100644 --- a/tests/tests/src/stdlib/Test.res +++ b/tests/tests/src/stdlib/Test.res @@ -1,6 +1,7 @@ // Test "framework" -@scope("process") @val external exit: int => unit = "exit" +type process = {mutable exitCode: int} +@val external process: process = "process" @scope("Error") @val external captureStackTrace: {..} => unit = "captureStackTrace" @module("@babel/code-frame") @val external codeFrameColumns: (string, {..}, {..}) => string = "codeFrameColumns" @@ -36,6 +37,7 @@ ${codeFrame} \u001b[39mRight: \u001b[31m${right}\u001b[0m ` Console.log(errorMessage) + process.exitCode = 1 // API: https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt let obj = Object.make() captureStackTrace(obj) diff --git a/tests/tests/src/test_string_const.mjs b/tests/tests/src/string_const_test.mjs similarity index 55% rename from tests/tests/src/test_string_const.mjs rename to tests/tests/src/string_const_test.mjs index e9d7c97859f..4fe1e4ba788 100644 --- a/tests/tests/src/test_string_const.mjs +++ b/tests/tests/src/string_const_test.mjs @@ -3,10 +3,10 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; -Mocha.describe("Test_string_const", () => { - Mocha.test("getUnsafe", () => { - Test_utils.eq("File \"test_string_const.res\", line 6, characters 7-14", "ghsogh".codePointAt(3), 111); - Test_utils.eq("File \"test_string_const.res\", line 7, characters 7-14", "ghsogh".codePointAt(-3), undefined); +Mocha.describe("String_const_test", () => { + Mocha.test("codePointAt", () => { + Test_utils.eq("File \"string_const_test.res\", line 6, characters 7-14", "ghsogh".codePointAt(3), 111); + Test_utils.eq("File \"string_const_test.res\", line 7, characters 7-14", "ghsogh".codePointAt(-3), undefined); }); }); diff --git a/tests/tests/src/test_string_const.res b/tests/tests/src/string_const_test.res similarity index 85% rename from tests/tests/src/test_string_const.res rename to tests/tests/src/string_const_test.res index c09e0891729..a39bfd89846 100644 --- a/tests/tests/src/test_string_const.res +++ b/tests/tests/src/string_const_test.res @@ -2,7 +2,7 @@ open Mocha open Test_utils describe(__MODULE__, () => { - test("getUnsafe", () => { + test("codePointAt", () => { eq(__LOC__, String.codePointAt("ghsogh", 3), Some(111)) eq(__LOC__, String.codePointAt("ghsogh", -3), None) }) diff --git a/tests/tests/src/test_eq.mjs b/tests/tests/src/test_eq.mjs deleted file mode 100644 index 83b3d3164c5..00000000000 --- a/tests/tests/src/test_eq.mjs +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -function f(x, y) { - return x + y | 0; -} - -export { - f, -} -/* No side effect */ diff --git a/tests/tests/src/test_eq.res b/tests/tests/src/test_eq.res deleted file mode 100644 index 31f91853472..00000000000 --- a/tests/tests/src/test_eq.res +++ /dev/null @@ -1 +0,0 @@ -let f = (x, y) => x + y diff --git a/tests/tests/src/test_literal.res b/tests/tests/src/test_literal.res index be8759ffa7a..69c2da6263d 100644 --- a/tests/tests/src/test_literal.res +++ b/tests/tests/src/test_literal.res @@ -10,5 +10,3 @@ let long_int_v = [1, 2, 3, 4, 5, 6] let short_int_v = [1] let empty: array = [] - -/* compile error */ diff --git a/tests/tests/src/test_pervasive.res b/tests/tests/src/test_pervasive.res index eefa2ae4b6e..1d7bea12e7f 100644 --- a/tests/tests/src/test_pervasive.res +++ b/tests/tests/src/test_pervasive.res @@ -24,6 +24,3 @@ let a15 = Math.log let a16 = Math.log10 let a17 = Math.log1p let a18 = \"**" -/* local variables: */ -/* compile-command: "ocamlc -dlambda -c test_pervasive.ml" */ -/* end: */ diff --git a/tests/tests/src/test_seq.res b/tests/tests/src/test_seq.res index 1059cc27185..23d1f459735 100644 --- a/tests/tests/src/test_seq.res +++ b/tests/tests/src/test_seq.res @@ -91,6 +91,3 @@ let add_help = speclist => { List.concat(speclist, List.concat(add1, add2)) } - -/* FIXME- not compatible with strict mode */ -/* let f x x = x */ diff --git a/tests/tests/src/test_string_case.res b/tests/tests/src/test_string_case.res index 8003b118929..6552e408f5b 100644 --- a/tests/tests/src/test_string_case.res +++ b/tests/tests/src/test_string_case.res @@ -4,7 +4,3 @@ let f = x => | "bcde" => 1 | _ => assert(false) } - -/* local variables: */ -/* compile-command: "ocamlc -dlambda -c string_case.ml && js_of_ocaml string_case.cmo --pretty -o string_case.1.js" */ -/* end: */ diff --git a/tests/tests/src/test_u.mjs b/tests/tests/src/test_u.mjs deleted file mode 100644 index a2c9e2d99ce..00000000000 --- a/tests/tests/src/test_u.mjs +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -function f(x) { - let v = x; - let sum = 0; - while (v > 0) { - sum = sum + v | 0; - v = v - 1 | 0; - }; - return sum; -} - -export { - f, -} -/* No side effect */ diff --git a/tests/tests/src/test_u.res b/tests/tests/src/test_u.res deleted file mode 100644 index a820f37fa4a..00000000000 --- a/tests/tests/src/test_u.res +++ /dev/null @@ -1,9 +0,0 @@ -let f = x => { - let v = ref(x) - let sum = ref(0) - while v.contents > 0 { - sum := sum.contents + v.contents - v.contents = v.contents - 1 - } - sum.contents -} diff --git a/tests/tests/src/test_utils.mjs b/tests/tests/src/test_utils.mjs index 8dbe369ec5c..6d3ed30222d 100644 --- a/tests/tests/src/test_utils.mjs +++ b/tests/tests/src/test_utils.mjs @@ -14,15 +14,9 @@ function throws(loc, f) { Nodeassert.throws(f, undefined, loc); } -function approxEq(loc, threshold, a, b) { - let diff = Math.abs(a - b); - Nodeassert.ok(diff <= threshold, loc); -} - export { ok, eq, throws, - approxEq, } /* node:assert Not a pure module */ diff --git a/tests/tests/src/test_utils.res b/tests/tests/src/test_utils.res index 4c54bda2681..119cefc04c2 100644 --- a/tests/tests/src/test_utils.res +++ b/tests/tests/src/test_utils.res @@ -1,12 +1,3 @@ let ok = (loc, a) => Node_assert.ok(a, ~message=loc) let eq = (loc, a, b) => Node_assert.deepEqual(a, b, ~message=loc) let throws = (loc, f) => Node_assert.throws(f, ~message=loc) - -/** -Approximate equality comparison with a threshold parameter. -Returns true if the absolute difference between two values is less than or equal to the threshold. -*/ -let approxEq = (loc, threshold, a, b) => { - let diff = Math.abs(a -. b) - Node_assert.ok(diff <= threshold, ~message=loc) -} diff --git a/tests/tests/src/tramp_fib.mjs b/tests/tests/src/tramp_fib_test.mjs similarity index 87% rename from tests/tests/src/tramp_fib.mjs rename to tests/tests/src/tramp_fib_test.mjs index 5dd085d7b2d..164c3b86454 100644 --- a/tests/tests/src/tramp_fib.mjs +++ b/tests/tests/src/tramp_fib_test.mjs @@ -69,9 +69,9 @@ function isOdd(n) { } } -Mocha.describe("Tramp_fib", () => { - Mocha.test("fibonacci trampoline", () => Test_utils.eq("File \"tramp_fib.res\", line 54, characters 7-14", iter(u), 89)); - Mocha.test("even/odd trampoline", () => Test_utils.eq("File \"tramp_fib.res\", line 58, characters 7-14", iter(isEven(20000)), true)); +Mocha.describe("Tramp_fib_test", () => { + Mocha.test("fibonacci trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 54, characters 7-14", iter(u), 89)); + Mocha.test("even/odd trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 58, characters 7-14", iter(isEven(20000)), true)); }); export { diff --git a/tests/tests/src/tramp_fib.res b/tests/tests/src/tramp_fib_test.res similarity index 100% rename from tests/tests/src/tramp_fib.res rename to tests/tests/src/tramp_fib_test.res diff --git a/tests/tests/src/test_zero_nullable.mjs b/tests/tests/src/zero_nullable_test.mjs similarity index 88% rename from tests/tests/src/test_zero_nullable.mjs rename to tests/tests/src/zero_nullable_test.mjs index bfe8b6dc6f3..49d0a407422 100644 --- a/tests/tests/src/test_zero_nullable.mjs +++ b/tests/tests/src/zero_nullable_test.mjs @@ -172,12 +172,12 @@ let Test_nullable = { f11: f11$1 }; -Mocha.describe("Test_zero_nullable", () => { - Mocha.test("Test_nullable.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 161, characters 51-58", f1$1(0), 1)); - Mocha.test("Test_nullable.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 162, characters 46-53", f1$1(null), 3)); - Mocha.test("Test_nullable.f1 with undefined", () => Test_utils.eq("File \"test_zero_nullable.res\", line 163, characters 51-58", f1$1(undefined), 3)); - Mocha.test("Test_null.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 165, characters 47-54", f1(0), 1)); - Mocha.test("Test_null.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 166, characters 42-49", f1(null), 3)); +Mocha.describe("Zero_nullable_test", () => { + Mocha.test("Test_nullable.f1 with return(0)", () => Test_utils.eq("File \"zero_nullable_test.res\", line 161, characters 51-58", f1$1(0), 1)); + Mocha.test("Test_nullable.f1 with null", () => Test_utils.eq("File \"zero_nullable_test.res\", line 162, characters 46-53", f1$1(null), 3)); + Mocha.test("Test_nullable.f1 with undefined", () => Test_utils.eq("File \"zero_nullable_test.res\", line 163, characters 51-58", f1$1(undefined), 3)); + Mocha.test("Test_null.f1 with return(0)", () => Test_utils.eq("File \"zero_nullable_test.res\", line 165, characters 47-54", f1(0), 1)); + Mocha.test("Test_null.f1 with null", () => Test_utils.eq("File \"zero_nullable_test.res\", line 166, characters 42-49", f1(null), 3)); }); let a = null; diff --git a/tests/tests/src/test_zero_nullable.res b/tests/tests/src/zero_nullable_test.res similarity index 100% rename from tests/tests/src/test_zero_nullable.res rename to tests/tests/src/zero_nullable_test.res