Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fhammerschmidt committed Jul 1, 2024
1 parent 22f71ab commit 2248733
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/FloatTests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ Test.run([
"clamp - min -infinity, max -infinity"
], Core__Float.clamp(PervasivesU.neg_infinity, PervasivesU.neg_infinity, 4.2), eq, PervasivesU.neg_infinity);

Test.run([
[
"FloatTests.res",
49,
20,
46
],
"Float.equal optimization"
], false, eq, false);

export {
eq ,
}
Expand Down
2 changes: 2 additions & 0 deletions test/FloatTests.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ Test.run(
eq,
neg_infinity,
)

Test.run(__POS_OF__("Float.equal optimization"), Float.equal(1., 3.), eq, false)
10 changes: 10 additions & 0 deletions test/IntTests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ Test.run([
"clamp - > min, > max"
], Core__Int.clamp(40, 40, 42), eq, 40);

Test.run([
[
"IntTests.res",
170,
20,
44
],
"Int.equal optimization"
], false, eq, false);

export {
eq ,
$$catch ,
Expand Down
2 changes: 2 additions & 0 deletions test/IntTests.res
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ Test.run(__POS_OF__("clamp - < min, < max"), Int.clamp(~min=50, ~max=60, 42), eq
Test.run(__POS_OF__("clamp - < min, > max"), Int.clamp(~min=50, ~max=40, 42), eq, 50) // min wins
Test.run(__POS_OF__("clamp - > min, < max"), Int.clamp(~min=40, ~max=60, 42), eq, 42)
Test.run(__POS_OF__("clamp - > min, > max"), Int.clamp(~min=40, ~max=40, 42), eq, 40)

Test.run(__POS_OF__("Int.equal optimization"), Int.equal(1, 3), eq, false)
21 changes: 21 additions & 0 deletions test/StringTests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Test from "./Test.mjs";
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";

var eq = Caml_obj.equal;

Test.run([
[
"StringTests.res",
5,
20,
47
],
"String.equal optimization"
], false, eq, false);

export {
eq ,
}
/* Not a pure module */
5 changes: 5 additions & 0 deletions test/StringTests.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
open RescriptCore

let eq = (a, b) => a == b

Test.run(__POS_OF__("String.equal optimization"), String.equal("one", "three"), eq, false)

0 comments on commit 2248733

Please sign in to comment.