commit e40d0ee7457bdddb177d2c98e03f033e1e94c62c
parent 23973120631b32df3ce446f79550adb9c9d39dba
Author: Jared Tobin <jared@jtobin.io>
Date: Mon, 3 Feb 2025 11:19:47 +0400
test: gut old stuff
Diffstat:
| M | test/Main.hs | | | 150 | ------------------------------------------------------------------------------- |
1 file changed, 0 insertions(+), 150 deletions(-)
diff --git a/test/Main.hs b/test/Main.hs
@@ -238,153 +238,3 @@ main = defaultMain $ testGroup "ppad-fixed" [
]
]
--- newtype Different a = Different (a, a)
--- deriving Show
---
--- instance (Q.Arbitrary a, Eq a) => Q.Arbitrary (Different a) where
--- arbitrary = do
--- a <- Q.arbitrary
--- b <- Q.arbitrary `Q.suchThat` (\b -> b /= a)
--- pure (Different (a, b))
---
--- -- second argument is no greater than first argument
--- -- second argument * third argument is no greater than first argument
--- newtype MulMonotonic = MulMonotonic (Integer, Integer, Integer)
--- deriving Show
---
--- instance Q.Arbitrary MulMonotonic where
--- arbitrary = do
--- Q.NonNegative a <- Q.arbitrary
--- m <- fmap fi (Q.arbitrary :: Q.Gen Word64)
--- Q.NonNegative b <-
--- Q.arbitrary `Q.suchThat` (\(Q.NonNegative b) -> b * m <= a)
--- pure (MulMonotonic (a, b, m))
-
--- -- properties -----------------------------------------------------------------
---
--- lt_matches :: Different (Q.NonNegative Integer) -> Bool
--- lt_matches (Different (Q.NonNegative a, Q.NonNegative b))
--- | a < b = to_word256 a `lt` to_word256 b
--- | otherwise = to_word256 b `lt` to_word256 a
---
--- gt_matches :: Different (Q.NonNegative Integer) -> Bool
--- gt_matches (Different (Q.NonNegative a, Q.NonNegative b))
--- | a > b = to_word256 a `gt` to_word256 b
--- | otherwise = to_word256 b `gt` to_word256 a
---
--- to_word256_inverts_to_integer :: Word256 -> Bool
--- to_word256_inverts_to_integer w256 =
--- to_word256 (to_integer w256) == w256
---
--- to_integer_inverts_to_word256 :: Q.NonNegative Integer -> Bool
--- to_integer_inverts_to_word256 (Q.NonNegative n) =
--- to_integer (to_word256 n) == n
---
--- or_matches :: Q.NonNegative Integer -> Q.NonNegative Integer -> Bool
--- or_matches (Q.NonNegative a) (Q.NonNegative b) =
--- to_integer (to_word256 a `or` to_word256 b) == a .|. b
---
--- and_matches :: Q.NonNegative Integer -> Q.NonNegative Integer -> Bool
--- and_matches (Q.NonNegative a) (Q.NonNegative b) =
--- to_integer (to_word256 a `and` to_word256 b) == a .&. b
---
--- xor_matches :: Q.NonNegative Integer -> Q.NonNegative Integer -> Bool
--- xor_matches (Q.NonNegative a) (Q.NonNegative b) =
--- to_integer (to_word256 a `xor` to_word256 b) == a .^. b
-
--- sub_matches :: Monotonic -> Bool
--- sub_matches (Monotonic (a, b)) =
--- to_integer (to_word256 a `sub` to_word256 b) == a - b
--- -- assertions ------------------------------------------------------------------
---
--- quotrem_r_case0 :: H.Assertion
--- quotrem_r_case0 = do
--- let !(P q r) = quotrem_r 2 4 4
--- H.assertEqual mempty (P 9223372036854775809 0) (P q r)
---
--- quotrem_r_case1 :: H.Assertion
--- quotrem_r_case1 = do
--- let !(P q r) = quotrem_r 0 4 2
--- H.assertEqual mempty (P 2 0) (P q r)
---
--- recip_2by1_case0 :: H.Assertion
--- recip_2by1_case0 = do
--- let !q = recip_2by1 (B.complement 4)
--- H.assertEqual mempty 5 q
---
--- recip_2by1_case1 :: H.Assertion
--- recip_2by1_case1 = do
--- let !q = recip_2by1 (B.complement 0xff)
--- H.assertEqual mempty 256 q
-
--- -- main -----------------------------------------------------------------------
---
--- comparison :: TestTree
--- comparison = testGroup "comparison" [
--- Q.testProperty "lt matches" $
--- Q.withMaxSuccess 1000 lt_matches
--- , Q.testProperty "gt matches" $
--- Q.withMaxSuccess 1000 gt_matches
--- ]
---
--- bits :: TestTree
--- bits = testGroup "bits" [
--- Q.testProperty "or matches" $
--- Q.withMaxSuccess 1000 or_matches
--- , Q.testProperty "and matches" $
--- Q.withMaxSuccess 1000 and_matches
--- , Q.testProperty "xor matches" $
--- Q.withMaxSuccess 1000 xor_matches
--- ]
---
--- inverses :: TestTree
--- inverses = testGroup "inverses" [
--- Q.testProperty "to_word256 . to_integer ~ id" $
--- Q.withMaxSuccess 1000 to_word256_inverts_to_integer
--- , Q.testProperty "to_integer . to_word256 ~ id (nonneg input)" $
--- Q.withMaxSuccess 1000 to_integer_inverts_to_word256
--- ]
---
--- arithmetic :: TestTree
--- arithmetic = testGroup "arithmetic" [
--- Q.testProperty "addition matches (nonneg)" $
--- Q.withMaxSuccess 1000 add_matches
--- , Q.testProperty "subtraction matches (nonneg, monotonic)" $
--- Q.withMaxSuccess 1000 sub_matches
--- , Q.testProperty "512-bit multiplication matches (nonneg, low bits)" $
--- Q.withMaxSuccess 1000 mul_512_matches
--- , Q.testProperty "division matches" $
--- Q.withMaxSuccess 1000 div_matches
--- , Q.testProperty "mod matches" $
--- Q.withMaxSuccess 1000 mod_matches
--- ]
---
--- utils :: TestTree
--- utils = testGroup "utils" [
--- Q.testProperty "mul_c matches integer multiplication" $
--- Q.withMaxSuccess 1000 mul_c_matches
--- , Q.testProperty "umul_hop: (hi * 2 ^ 64 + lo) = z + (x * y)" $
--- Q.withMaxSuccess 1000 umul_hop_predicate_holds
--- , Q.testProperty "umul_step: (hi * 2 ^ 64 + lo) = z + (x * y) + c" $
--- Q.withMaxSuccess 1000 umul_step_predicate_holds
--- ]
---
--- main :: IO ()
--- main = defaultMain $
--- testGroup "ppad-fixed" [
--- testGroup "property tests" [
--- comparison
--- , utils
--- , inverses
--- , bits
--- , arithmetic
--- ]
--- , testGroup "unit tests" [
--- H.testCase "quotrem_r matches case0" quotrem_r_case0
--- , H.testCase "quotrem_r matches case1" quotrem_r_case1
--- , H.testCase "recip_2by1 matches case0" recip_2by1_case0
--- , H.testCase "recip_2by1 matches case1" recip_2by1_case1
--- , H.testCase "quotrem_2by1 matches case0" quotrem_2by1_case0
--- ]
--- ]
---