From b7f268d4a28dc80bec9a241de20ab5d9b4112792 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:28 +0200 Subject: [PATCH 01/12] Remove unused bindings from the docstring tests' Node module Path.join2, Process.cwd/argv/exit/env, Fs.existsSync/mkdirSync/ writeFileSync/readFileSync, ChildProcess.execSync and the top-level import.meta.dirname external are used by neither DocTest.res nor SpawnAsync.res (DocTest derives its directory from import.meta.url). Externals emit no JavaScript, so Node.res.js is unchanged. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- scripts/res/GenApiDocs.res | 2 -- tests/docstring_tests/Node.res | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/res/GenApiDocs.res b/scripts/res/GenApiDocs.res index bf72d64cdf..477f61f588 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/docstring_tests/Node.res b/tests/docstring_tests/Node.res index bcdd75c2b4..29783b629a 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" From b8438cc690209bd7b6c22de4a34a4bff0c92f2ad Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:29 +0200 Subject: [PATCH 02/12] Run the stdlib String and dynamic-import tests Stdlib_StringTests and Stdlib_ImportTests hold Test.run assertions, but no entry point included them, so they never executed; Stdlib_TestSuite now includes both (they pass). Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/tests/src/stdlib/Stdlib_TestSuite.mjs | 7 ++++++- tests/tests/src/stdlib/Stdlib_TestSuite.res | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/tests/src/stdlib/Stdlib_TestSuite.mjs b/tests/tests/src/stdlib/Stdlib_TestSuite.mjs index 1d33e63055..e64d42c643 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 6ea9e4ed2d..e39543615a 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 From 8d3e4b2d74985407ce1491d9977a0d3046126622 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:29 +0200 Subject: [PATCH 03/12] Make a failing stdlib Test.run fail the test process Test.run only logged a failure, so node Stdlib_TestSuite.mjs exited 0 and scripts/test.js passed regardless; it now sets process.exitCode to 1, so the remaining assertions still run and the suite fails at exit. The unused process.exit external is gone. All current assertions pass; a deliberately failing one makes the suite exit 1. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/tests/src/stdlib/Test.mjs | 1 + tests/tests/src/stdlib/Test.res | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/tests/src/stdlib/Test.mjs b/tests/tests/src/stdlib/Test.mjs index bcb1b4e044..c9d7517e67 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 6bd7c8659f..ab6122a632 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) From 87a61bd2f2f27dfb21db74feb0fbf0108b41c45c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:31 +0200 Subject: [PATCH 04/12] Name the unloaded mocha suites *_test so mocha runs them scripts/test.js runs mocha on tests/tests/src/**/*_test.mjs, so the describe blocks in arity_deopt, bs_ignore_effect, inline_map_demo, int_poly_var, recursive_module, test_case_opt_collision, test_for_of, test_string_const, test_zero_nullable and tramp_fib never ran. Each is renamed to a *_test name (recursive_module2_test, since recursive_module_test exists; the test_ prefix is dropped where the suffix is added) and its regenerated .mjs committed; the module name and __LOC__ strings change with the file name. All 22 tests pass (mocha 580 passing, from 558). Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- .../{arity_deopt.mjs => arity_deopt_test.mjs} | 10 +++++----- .../{arity_deopt.res => arity_deopt_test.res} | 0 ...nore_effect.mjs => bs_ignore_effect_test.mjs} | 6 +++--- ...nore_effect.res => bs_ignore_effect_test.res} | 0 ...collision.mjs => case_opt_collision_test.mjs} | 6 +++--- ...collision.res => case_opt_collision_test.res} | 0 .../src/{test_for_of.mjs => for_of_test.mjs} | 16 ++++++++-------- .../src/{test_for_of.res => for_of_test.res} | 0 ...ine_map_demo.mjs => inline_map_demo_test.mjs} | 12 ++++++------ ...ine_map_demo.res => inline_map_demo_test.res} | 0 .../{int_poly_var.mjs => int_poly_var_test.mjs} | 6 +++--- .../{int_poly_var.res => int_poly_var_test.res} | 0 ...ive_module.mjs => recursive_module2_test.mjs} | 8 ++++---- ...ive_module.res => recursive_module2_test.res} | 0 ...st_string_const.mjs => string_const_test.mjs} | 6 +++--- ...st_string_const.res => string_const_test.res} | 0 .../src/{tramp_fib.mjs => tramp_fib_test.mjs} | 6 +++--- .../src/{tramp_fib.res => tramp_fib_test.res} | 0 ..._zero_nullable.mjs => zero_nullable_test.mjs} | 12 ++++++------ ..._zero_nullable.res => zero_nullable_test.res} | 0 20 files changed, 44 insertions(+), 44 deletions(-) rename tests/tests/src/{arity_deopt.mjs => arity_deopt_test.mjs} (55%) rename tests/tests/src/{arity_deopt.res => arity_deopt_test.res} (100%) rename tests/tests/src/{bs_ignore_effect.mjs => bs_ignore_effect_test.mjs} (73%) rename tests/tests/src/{bs_ignore_effect.res => bs_ignore_effect_test.res} (100%) rename tests/tests/src/{test_case_opt_collision.mjs => case_opt_collision_test.mjs} (73%) rename tests/tests/src/{test_case_opt_collision.res => case_opt_collision_test.res} (100%) rename tests/tests/src/{test_for_of.mjs => for_of_test.mjs} (86%) rename tests/tests/src/{test_for_of.res => for_of_test.res} (100%) rename tests/tests/src/{inline_map_demo.mjs => inline_map_demo_test.mjs} (92%) rename tests/tests/src/{inline_map_demo.res => inline_map_demo_test.res} (100%) rename tests/tests/src/{int_poly_var.mjs => int_poly_var_test.mjs} (90%) rename tests/tests/src/{int_poly_var.res => int_poly_var_test.res} (100%) rename tests/tests/src/{recursive_module.mjs => recursive_module2_test.mjs} (81%) rename tests/tests/src/{recursive_module.res => recursive_module2_test.res} (100%) rename tests/tests/src/{test_string_const.mjs => string_const_test.mjs} (63%) rename tests/tests/src/{test_string_const.res => string_const_test.res} (100%) rename tests/tests/src/{tramp_fib.mjs => tramp_fib_test.mjs} (87%) rename tests/tests/src/{tramp_fib.res => tramp_fib_test.res} (100%) rename tests/tests/src/{test_zero_nullable.mjs => zero_nullable_test.mjs} (88%) rename tests/tests/src/{test_zero_nullable.res => zero_nullable_test.res} (100%) 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 7d5964fc77..ca0d033b47 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_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 d2e755cc72..fc56b96430 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 596e332061..61395c67a7 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/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 f9707126af..8fcbe9902d 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/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 17790a7b1d..e65a00890a 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_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 46de835200..e8be67c412 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/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 12f04b3970..77f7edb4e6 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/test_string_const.mjs b/tests/tests/src/string_const_test.mjs similarity index 63% rename from tests/tests/src/test_string_const.mjs rename to tests/tests/src/string_const_test.mjs index e9d7c97859..64104ada35 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.describe("String_const_test", () => { 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); + 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 100% rename from tests/tests/src/test_string_const.res rename to tests/tests/src/string_const_test.res 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 5dd085d7b2..164c3b8645 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 bfe8b6dc6f..49d0a40742 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 From 42a8eaab1d6ea4bd63c0b7c5926ce6e47ec036ce Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:32 +0200 Subject: [PATCH 05/12] Remove the unused approxEq test helpers Test_utils.approxEq in tests/tests/src and tests/belt_tests/src has no caller in either suite; the tests/tests copy's doc comment also said it returns a bool, while it asserts. Their compiled test_utils.mjs lose the export. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/belt_tests/src/test_utils.mjs | 6 ------ tests/belt_tests/src/test_utils.res | 5 ----- tests/tests/src/test_utils.mjs | 6 ------ tests/tests/src/test_utils.res | 9 --------- 4 files changed, 26 deletions(-) diff --git a/tests/belt_tests/src/test_utils.mjs b/tests/belt_tests/src/test_utils.mjs index 8dbe369ec5..6d3ed30222 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 a713650a8f..119cefc04c 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/tests/src/test_utils.mjs b/tests/tests/src/test_utils.mjs index 8dbe369ec5..6d3ed30222 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 4c54bda268..119cefc04c 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) -} From 20f0cacf687402488f3252c9822bb8b778f1724a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:32 +0200 Subject: [PATCH 06/12] Remove duplicate codegen snapshot tests Each removed source repeats another test's program: DerivingAccessorsUncurried is DerivingAccessorsCurried plus a no-op @@uncurried (byte-identical .mjs); conditional/cond_c equals cond_b and cond_a_C equals cond_a_B up to the module name; test_u is test_fib.res:54-62; test_eq is the first line of test_ari.res; belt test_for_map is test_for_map2 up to the alias name. None is imported by another test. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/belt_tests/src/test_for_map.mjs | 21 ------- tests/belt_tests/src/test_for_map.res | 12 ---- .../tests/src/DerivingAccessorsUncurried.mjs | 57 ------------------- .../tests/src/DerivingAccessorsUncurried.res | 21 ------- tests/tests/src/conditional/cond_a_C.mjs | 16 ------ tests/tests/src/conditional/cond_a_C.res | 6 -- tests/tests/src/conditional/cond_c.mjs | 9 --- tests/tests/src/conditional/cond_c.res | 1 - tests/tests/src/test_eq.mjs | 11 ---- tests/tests/src/test_eq.res | 1 - tests/tests/src/test_u.mjs | 17 ------ tests/tests/src/test_u.res | 9 --- 12 files changed, 181 deletions(-) delete mode 100644 tests/belt_tests/src/test_for_map.mjs delete mode 100644 tests/belt_tests/src/test_for_map.res delete mode 100644 tests/tests/src/DerivingAccessorsUncurried.mjs delete mode 100644 tests/tests/src/DerivingAccessorsUncurried.res delete mode 100644 tests/tests/src/conditional/cond_a_C.mjs delete mode 100644 tests/tests/src/conditional/cond_a_C.res delete mode 100644 tests/tests/src/conditional/cond_c.mjs delete mode 100644 tests/tests/src/conditional/cond_c.res delete mode 100644 tests/tests/src/test_eq.mjs delete mode 100644 tests/tests/src/test_eq.res delete mode 100644 tests/tests/src/test_u.mjs delete mode 100644 tests/tests/src/test_u.res 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 b14e15e2e1..0000000000 --- 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 3af916caf9..0000000000 --- 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/tests/src/DerivingAccessorsUncurried.mjs b/tests/tests/src/DerivingAccessorsUncurried.mjs deleted file mode 100644 index a816cc5575..0000000000 --- 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 b80b5b1b3e..0000000000 --- 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/conditional/cond_a_C.mjs b/tests/tests/src/conditional/cond_a_C.mjs deleted file mode 100644 index 50cff7a715..0000000000 --- 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 fe61d4890d..0000000000 --- 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 522d8f9212..0000000000 --- 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 e1b898c188..0000000000 --- a/tests/tests/src/conditional/cond_c.res +++ /dev/null @@ -1 +0,0 @@ -let value = 3 diff --git a/tests/tests/src/test_eq.mjs b/tests/tests/src/test_eq.mjs deleted file mode 100644 index 83b3d3164c..0000000000 --- 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 31f9185347..0000000000 --- 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_u.mjs b/tests/tests/src/test_u.mjs deleted file mode 100644 index a2c9e2d99c..0000000000 --- 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 a820f37fa4..0000000000 --- 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 -} From 2d7aee9cb7e70065e2a041cce621b947f3bffb7d Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:33 +0200 Subject: [PATCH 07/12] Remove test sources that hold only comments gpr_441.res, gpr_1759_test.res and gpr_4494_test.res are entirely commented out, and debug_tmp.res is a @@config with commented-out code; each compiles to the empty-output stub and nothing imports them. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/tests/src/debug_tmp.mjs | 2 -- tests/tests/src/debug_tmp.res | 21 --------------------- tests/tests/src/gpr_1759_test.mjs | 2 -- tests/tests/src/gpr_1759_test.res | 6 ------ tests/tests/src/gpr_441.mjs | 2 -- tests/tests/src/gpr_441.res | 4 ---- tests/tests/src/gpr_4494_test.mjs | 2 -- tests/tests/src/gpr_4494_test.res | 1 - 8 files changed, 40 deletions(-) delete mode 100644 tests/tests/src/debug_tmp.mjs delete mode 100644 tests/tests/src/debug_tmp.res delete mode 100644 tests/tests/src/gpr_1759_test.mjs delete mode 100644 tests/tests/src/gpr_1759_test.res delete mode 100644 tests/tests/src/gpr_441.mjs delete mode 100644 tests/tests/src/gpr_441.res delete mode 100644 tests/tests/src/gpr_4494_test.mjs delete mode 100644 tests/tests/src/gpr_4494_test.res diff --git a/tests/tests/src/debug_tmp.mjs b/tests/tests/src/debug_tmp.mjs deleted file mode 100644 index d856702bfe..0000000000 --- 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 950ffcf04c..0000000000 --- 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/gpr_1759_test.mjs b/tests/tests/src/gpr_1759_test.mjs deleted file mode 100644 index d856702bfe..0000000000 --- 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 8e6e2fd9df..0000000000 --- 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_441.mjs b/tests/tests/src/gpr_441.mjs deleted file mode 100644 index d856702bfe..0000000000 --- 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 7c33000321..0000000000 --- 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 d856702bfe..0000000000 --- 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 97fb80dbff..0000000000 --- a/tests/tests/src/gpr_4494_test.res +++ /dev/null @@ -1 +0,0 @@ -/* disable it temporarily since it's TNTE */ From cb62830c411b74b0aecf62f9d257c1030fb3feb1 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:37 +0200 Subject: [PATCH 08/12] Remove stale comments from tests/tests sources The removed comments state what the code no longer does: DotDotDot's commented-out spread parses and compiles; bs_auto_uncurry's arity-adjust wrapper and a_scope_bug's even$1 renaming are absent from the committed .mjs; pipe_send_readline has no [@@bs.xx]; test_literal compiles; test_dup_param shows duplicate parameters compile in strict mode (test_seq's FIXME); test_pervasive and test_string_case carried OCaml compile-command footers. int_overflow_test's hex comments were swapped. No .mjs changes. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/tests/src/DotDotDot.res | 3 --- tests/tests/src/a_scope_bug.res | 3 --- tests/tests/src/bs_auto_uncurry.res | 1 - tests/tests/src/int_overflow_test.res | 4 ++-- tests/tests/src/pipe_send_readline.res | 2 -- tests/tests/src/test_literal.res | 2 -- tests/tests/src/test_pervasive.res | 3 --- tests/tests/src/test_seq.res | 3 --- tests/tests/src/test_string_case.res | 4 ---- 9 files changed, 2 insertions(+), 23 deletions(-) diff --git a/tests/tests/src/DotDotDot.res b/tests/tests/src/DotDotDot.res index 0a0cf79e94..febc517bb8 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 9a7faff9db..d683578f27 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/bs_auto_uncurry.res b/tests/tests/src/bs_auto_uncurry.res index 673049bcf9..507e03087e 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/int_overflow_test.res b/tests/tests/src/int_overflow_test.res index bd013a3ed1..542c7dcd91 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/pipe_send_readline.res b/tests/tests/src/pipe_send_readline.res index 9220df88b4..f58e460005 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/test_literal.res b/tests/tests/src/test_literal.res index be8759ffa7..69c2da6263 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 eefa2ae4b6..1d7bea12e7 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 1059cc2718..23d1f45973 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 8003b11892..6552e408f5 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: */ From 55606af04604790e16d00f6abb6f6f36ea8e3830 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:38 +0200 Subject: [PATCH 09/12] Fix test assertions and labels that disagree with their code float_test checked generic_lessequal against nan twice per order and float_lessequal never; it now checks each once. optional_ffi_test's second pair read counter instead of counter2, the ref bug_to_fix2 updates. flexible_array_test computed the 500-element sort comparison and discarded it; it is now asserted. Labels: Stdlib_PromiseTest "value should be 5" asserts 10, string_const_test "getUnsafe" tests codePointAt, belt_list_test had a "droo" test and two named "makeBy". Belt comments: list_test called a five-int list a tuple, ticker's doc said sort_uniq where the code sorts, and bs_map_set_dict_test claimed assertions above that only log. All pass (mocha 580, stdlib suite). Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/belt_tests/src/belt_list_test.mjs | 4 ++-- tests/belt_tests/src/belt_list_test.res | 4 ++-- tests/belt_tests/src/bs_map_set_dict_test.res | 2 +- tests/belt_tests/src/list_test.res | 2 +- tests/belt_tests/src/ticker.res | 2 +- tests/tests/src/flexible_array_test.mjs | 12 +++++++++++- tests/tests/src/flexible_array_test.res | 5 ++++- tests/tests/src/float_test.mjs | 4 ++-- tests/tests/src/float_test.res | 4 ++-- tests/tests/src/optional_ffi_test.mjs | 2 +- tests/tests/src/optional_ffi_test.res | 2 +- tests/tests/src/stdlib/Stdlib_PromiseTest.mjs | 4 ++-- tests/tests/src/stdlib/Stdlib_PromiseTest.res | 2 +- tests/tests/src/string_const_test.mjs | 2 +- tests/tests/src/string_const_test.res | 2 +- 15 files changed, 33 insertions(+), 20 deletions(-) diff --git a/tests/belt_tests/src/belt_list_test.mjs b/tests/belt_tests/src/belt_list_test.mjs index e2ac66043a..a4ce65569c 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 9f84baa3df..8367232b89 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 d2aa135c4d..07a105b02a 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 06df039e4f..6c13149084 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/ticker.res b/tests/belt_tests/src/ticker.res index 681004fa37..b462b74ddb 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/tests/src/flexible_array_test.mjs b/tests/tests/src/flexible_array_test.mjs index 5f346368a2..5ee6828a63 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 17fc07b69c..a54df1f972 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 20d05b1cdb..d02bf02aec 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 a0618c51eb..0a11afd1df 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/optional_ffi_test.mjs b/tests/tests/src/optional_ffi_test.mjs index 295aebd62b..c29f82af0d 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 49dc9ca75f..6a22bb1a68 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/stdlib/Stdlib_PromiseTest.mjs b/tests/tests/src/stdlib/Stdlib_PromiseTest.mjs index fc1a804770..e8d01aceb1 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 0040daba61..a5c89de490 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/string_const_test.mjs b/tests/tests/src/string_const_test.mjs index 64104ada35..4fe1e4ba78 100644 --- a/tests/tests/src/string_const_test.mjs +++ b/tests/tests/src/string_const_test.mjs @@ -4,7 +4,7 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; Mocha.describe("String_const_test", () => { - Mocha.test("getUnsafe", () => { + 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/string_const_test.res b/tests/tests/src/string_const_test.res index c09e089172..a39bfd8984 100644 --- a/tests/tests/src/string_const_test.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) }) From 4f4f1d81f47051a8cbe30c852e5030b5571baf46 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:38 +0200 Subject: [PATCH 10/12] Remove gpr_2789_test, which asserts only 1 = 1 Its one mocha test is named "weak array commented out tests" and says the tests are commented out, but the file holds no commented-out tests: its only assertion is eq(__LOC__, 1, 1), and nothing imports it. Signed-off-by: Cristiano Calcagno Co-Authored-By: Claude Opus 5.5 --- tests/tests/src/gpr_2789_test.mjs | 10 ---------- tests/tests/src/gpr_2789_test.res | 9 --------- 2 files changed, 19 deletions(-) delete mode 100644 tests/tests/src/gpr_2789_test.mjs delete mode 100644 tests/tests/src/gpr_2789_test.res diff --git a/tests/tests/src/gpr_2789_test.mjs b/tests/tests/src/gpr_2789_test.mjs deleted file mode 100644 index 6060465b15..0000000000 --- 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 ad3f063a2f..0000000000 --- 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) - }) -}) From 8d6173d71dbb74d8a7c2dc142d8101e63f4f4f6f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 06:57:50 +0200 Subject: [PATCH 11/12] Remove the unused notDeepEqual binding from tests/tests node_assert No tests/tests source calls Node_assert.notDeepEqual or aliases the module. The binding is an external, so node_assert.mjs is unchanged. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Cristiano Calcagno --- tests/tests/src/node_assert.res | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/tests/src/node_assert.res b/tests/tests/src/node_assert.res index 57e4187835..517fb80289 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" From 9419b6d1fd6cfa63825cffebbe75981177f7d27e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 2 Oct 2026 22:07:51 +0200 Subject: [PATCH 12/12] Run the dynamic-import test in the stdlib suite Stdlib_ImportTests ended with main->ignore, which discards the async function instead of calling it, so its assertion never ran. Call main() so a failing assertion sets the exit code of Stdlib_TestSuite. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Cristiano Calcagno --- tests/tests/src/stdlib/Stdlib_ImportTests.mjs | 4 +++- tests/tests/src/stdlib/Stdlib_ImportTests.res | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/tests/src/stdlib/Stdlib_ImportTests.mjs b/tests/tests/src/stdlib/Stdlib_ImportTests.mjs index 729eab1819..56020b0668 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 b25f7779eb..fd5deba3d8 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