Skip to content

Commit

Permalink
chore: Supress warnings when testing fromNumber (#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Mar 4, 2024
1 parent e4b97ea commit c790adc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/test/stdlib/rational.test.gr
Expand Up @@ -15,6 +15,9 @@ use Rational.{
}

// Rational.fromNumber
// Operations Tests
// Suppress warnings about using `fromNumber` on constants, since that's what we want to test.
let fromNumber = fromNumber
assert fromNumber(1/2) == 1/2r
assert fromNumber(0) == 0/1r
assert fromNumber(1/1) == 1/1r
Expand Down
14 changes: 12 additions & 2 deletions compiler/test/suites/numbers.re
Expand Up @@ -179,12 +179,22 @@ describe("numbers", ({test, testSkip}) => {
);
assertRunError(
"shortnum_err1",
{|from "uint8" include Uint8; print(Uint8.fromNumber(-1))|},
{|
from "uint8" include Uint8;
// Suppress warnings about using `fromNumber` on constants, since that's what we want to test.
let fromNumber = Uint8.fromNumber
print(fromNumber(-1))
|},
"Overflow: Number overflow",
);
assertRunError(
"shortnum_err2",
{|from "uint8" include Uint8; print(Uint8.fromNumber(256))|},
{|
from "uint8" include Uint8;
// Suppress warnings about using `fromNumber` on constants, since that's what we want to test.
let fromNumber = Uint8.fromNumber
print(fromNumber(256))
|},
"Overflow: Number overflow",
);
assertCompileError(
Expand Down

0 comments on commit c790adc

Please sign in to comment.