Skip to content

Commit 0ef247a

Browse files
committed
add a test
1 parent 9ba6840 commit 0ef247a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tests/tests/src/exponentiation_test.mjs

+14-9
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@ function eq(loc, x, y) {
1616

1717
let intPow = ((a, b) => Math.pow(a, b) | 0);
1818

19-
eq("File \"exponentiation_test.res\", line 10, characters 5-12", 2 ** 3 ** 2, Math.pow(2, Math.pow(3, 2)));
19+
let four = 4;
2020

21-
eq("File \"exponentiation_test.res\", line 11, characters 5-12", 2 ** (-3) ** 2, Math.pow(2, Math.pow(-3, 2)));
21+
eq("File \"exponentiation_test.res\", line 11, characters 5-12", 2 ** 3 ** 2, Math.pow(2, Math.pow(3, 2)));
2222

23-
eq("File \"exponentiation_test.res\", line 12, characters 5-12", (2 ** 3) ** 2, Math.pow(Math.pow(2, 3), 2));
23+
eq("File \"exponentiation_test.res\", line 12, characters 5-12", 2 ** (-3) ** 2, Math.pow(2, Math.pow(-3, 2)));
2424

25-
eq("File \"exponentiation_test.res\", line 13, characters 5-12", (-2) ** 2, Math.pow(-2, 2));
25+
eq("File \"exponentiation_test.res\", line 13, characters 5-12", (2 ** 3) ** 2, Math.pow(Math.pow(2, 3), 2));
2626

27-
eq("File \"exponentiation_test.res\", line 15, characters 5-12", 512, intPow(2, intPow(3, 2)));
27+
eq("File \"exponentiation_test.res\", line 14, characters 5-12", (-2) ** 2, Math.pow(-2, 2));
2828

29-
eq("File \"exponentiation_test.res\", line 16, characters 5-12", 512, intPow(2, intPow(-3, 2)));
29+
eq("File \"exponentiation_test.res\", line 16, characters 5-12", 512, intPow(2, intPow(3, 2)));
3030

31-
eq("File \"exponentiation_test.res\", line 17, characters 5-12", 64, intPow(intPow(2, 3), 2));
31+
eq("File \"exponentiation_test.res\", line 17, characters 5-12", 512, intPow(2, intPow(-3, 2)));
3232

33-
eq("File \"exponentiation_test.res\", line 18, characters 5-12", -2147483648, intPow(-2, 31));
33+
eq("File \"exponentiation_test.res\", line 18, characters 5-12", 64, intPow(intPow(2, 3), 2));
3434

35-
eq("File \"exponentiation_test.res\", line 19, characters 5-12", 0, intPow(2, 32));
35+
eq("File \"exponentiation_test.res\", line 19, characters 5-12", -2147483648, intPow(-2, 31));
36+
37+
eq("File \"exponentiation_test.res\", line 20, characters 5-12", 0, intPow(2, 32));
38+
39+
eq("File \"exponentiation_test.res\", line 22, characters 5-12", 256, four ** four | 0);
3640

3741
Mt.from_pair_suites("Exponentiation_test", suites.contents);
3842

@@ -41,5 +45,6 @@ export {
4145
test_id,
4246
eq,
4347
intPow,
48+
four,
4449
}
4550
/* Not a pure module */

tests/tests/src/exponentiation_test.res

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y)
55
external jsPow: (float, float) => float = "Math.pow"
66

77
let intPow: (int, int) => int = %raw(`(a, b) => Math.pow(a, b) | 0`)
8+
let four: int = %raw(`4`)
89

910
let () = {
1011
eq(__LOC__, 2. ** 3. ** 2., jsPow(2., jsPow(3., 2.)))
@@ -17,6 +18,8 @@ let () = {
1718
eq(__LOC__, (2 ** 3) ** 2, intPow(intPow(2, 3), 2))
1819
eq(__LOC__, -2 ** 31, intPow(-2, 31))
1920
eq(__LOC__, 2 ** 32, intPow(2, 32))
21+
22+
eq(__LOC__, 4 ** 4, four ** four)
2023
}
2124

2225
let () = Mt.from_pair_suites(__MODULE__, suites.contents)

0 commit comments

Comments
 (0)