Skip to content

Commit 8af675c

Browse files
committed
more exponentiation tests
1 parent f10bbf8 commit 8af675c

4 files changed

+67
-22
lines changed

tests/tests/src/exponentiation_precedence_test.mjs

-18
This file was deleted.

tests/tests/src/exponentiation_precedence_test.res

-4
This file was deleted.
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
import * as Mt from "./mt.mjs";
4+
5+
let suites = {
6+
contents: /* [] */0
7+
};
8+
9+
let test_id = {
10+
contents: 0
11+
};
12+
13+
function eq(loc, x, y) {
14+
Mt.eq_suites(test_id, suites, loc, x, y);
15+
}
16+
17+
let intPow = ((a, b) => Math.pow(a, b) | 0);
18+
19+
eq("File \"exponentiation_test.res\", line 10, characters 5-12", 2 ** 3 ** 2, Math.pow(2, Math.pow(3, 2)));
20+
21+
eq("File \"exponentiation_test.res\", line 11, characters 5-12", 2 ** (-3) ** 2, Math.pow(2, Math.pow(-3, 2)));
22+
23+
eq("File \"exponentiation_test.res\", line 12, characters 5-12", (2 ** 3) ** 2, Math.pow(Math.pow(2, 3), 2));
24+
25+
eq("File \"exponentiation_test.res\", line 13, characters 5-12", (-2) ** 2, Math.pow(-2, 2));
26+
27+
eq("File \"exponentiation_test.res\", line 15, characters 5-12", 512, intPow(2, intPow(3, 2)));
28+
29+
eq("File \"exponentiation_test.res\", line 16, characters 5-12", 512, intPow(2, intPow(-3, 2)));
30+
31+
eq("File \"exponentiation_test.res\", line 17, characters 5-12", 64, intPow(intPow(2, 3), 2));
32+
33+
eq("File \"exponentiation_test.res\", line 18, characters 5-12", -2147483648, intPow(-2, 31));
34+
35+
eq("File \"exponentiation_test.res\", line 19, characters 5-12", 0, intPow(2, 32));
36+
37+
Mt.from_pair_suites("Exponentiation_test", suites.contents);
38+
39+
export {
40+
suites,
41+
test_id,
42+
eq,
43+
intPow,
44+
}
45+
/* Not a pure module */
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let suites: ref<Mt.pair_suites> = ref(list{})
2+
let test_id = ref(0)
3+
let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y)
4+
5+
external jsPow: (float, float) => float = "Math.pow"
6+
7+
let intPow: (int, int) => int = %raw(`(a, b) => Math.pow(a, b) | 0`)
8+
9+
let () = {
10+
eq(__LOC__, 2. ** 3. ** 2., jsPow(2., jsPow(3., 2.)))
11+
eq(__LOC__, 2. ** -3. ** 2., jsPow(2., jsPow(-3., 2.)))
12+
eq(__LOC__, (2. ** 3.) ** 2., jsPow(jsPow(2., 3.), 2.))
13+
eq(__LOC__, -2. ** 2., jsPow(-2., 2.))
14+
15+
eq(__LOC__, 2 ** 3 ** 2, intPow(2, intPow(3, 2)))
16+
eq(__LOC__, 2 ** -3 ** 2, intPow(2, intPow(-3, 2)))
17+
eq(__LOC__, (2 ** 3) ** 2, intPow(intPow(2, 3), 2))
18+
eq(__LOC__, -2 ** 31, intPow(-2, 31))
19+
eq(__LOC__, 2 ** 32, intPow(2, 32))
20+
}
21+
22+
let () = Mt.from_pair_suites(__MODULE__, suites.contents)

0 commit comments

Comments
 (0)