fixed

Pure Haskell large fixed-width integers.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit 08373ec62cf445acd82b9957eff1057be6f9bd67
parent 1b2e9d72f98f67639b6ab8d2fa4cc4ee3a0141d9
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu, 23 Jan 2025 10:31:06 +0400

test: bigger range for monotonic instance

Diffstat:
Mtest/Main.hs | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/Main.hs b/test/Main.hs @@ -31,13 +31,14 @@ instance (Q.Arbitrary a, Eq a) => Q.Arbitrary (Different a) where pure (Different (a, b)) -- second argument is no greater than first argument -newtype Monotonic a = Monotonic (a, a) +newtype Monotonic = Monotonic (Integer, Integer) deriving Show -instance (Q.Arbitrary a, Ord a) => Q.Arbitrary (Monotonic a) where +instance Q.Arbitrary Monotonic where arbitrary = do - a <- Q.arbitrary - b <- Q.arbitrary `Q.suchThat` (\b -> b <= a) + a <- Q.chooseInteger (0, 2 ^ (256 :: Int) - 1) + b <- (Q.chooseInteger (0, 2 ^ (256 :: Int) - 1)) + `Q.suchThat` (\b -> b <= a) pure (Monotonic (a, b)) -- second argument * third argument is no greater than first argument @@ -128,8 +129,8 @@ add_matches :: Q.NonNegative Integer -> Q.NonNegative Integer -> Bool add_matches (Q.NonNegative a) (Q.NonNegative b) = to_integer (to_word256 a `add` to_word256 b) == a + b -sub_matches :: Monotonic (Q.NonNegative Integer) -> Bool -sub_matches (Monotonic (Q.NonNegative a, Q.NonNegative b)) = +sub_matches :: Monotonic -> Bool +sub_matches (Monotonic (a, b)) = to_integer (to_word256 a `sub` to_word256 b) == a - b mul_lo_matches :: Q.NonNegative Integer -> Q.NonNegative Integer -> Bool