From c790adc1775a835a147abb57bfc979322b952e99 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 4 Mar 2024 08:14:57 -0700 Subject: [PATCH] chore: Supress warnings when testing fromNumber (#2058) --- compiler/test/stdlib/rational.test.gr | 3 +++ compiler/test/suites/numbers.re | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler/test/stdlib/rational.test.gr b/compiler/test/stdlib/rational.test.gr index 708805f16..ca1f6435a 100644 --- a/compiler/test/stdlib/rational.test.gr +++ b/compiler/test/stdlib/rational.test.gr @@ -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 diff --git a/compiler/test/suites/numbers.re b/compiler/test/suites/numbers.re index fcc697475..82b432ddc 100644 --- a/compiler/test/suites/numbers.re +++ b/compiler/test/suites/numbers.re @@ -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(