fixed

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

commit 0be10b6a613880aea3fa87096f5ec2eb77426e76
parent a9fc6951f62aae7c3bcd53dab80f2d73aa7d7aa3
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 22 Jan 2025 12:24:58 +0400

test: conversion properties

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

diff --git a/test/Main.hs b/test/Main.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} + module Main where import Data.Word.Extended @@ -16,14 +18,16 @@ to_word256_inverts_to_integer :: Word256 -> Bool to_word256_inverts_to_integer w256 = to_word256 (to_integer w256) == w256 -to_integer_inverts_to_word256 :: Integer -> Bool -to_integer_inverts_to_word256 n = +-- doesn't hold for negative inputs +to_integer_inverts_to_word256 :: (Q.NonNegative Integer) -> Bool +to_integer_inverts_to_word256 (Q.NonNegative n) = to_integer (to_word256 n) == n +conversion :: TestTree conversion = testGroup "conversion" [ Q.testProperty "to_word256 . to_integer ~ id" $ Q.withMaxSuccess 1000 to_word256_inverts_to_integer - , Q.testProperty "to_integer . to_word256 ~ id" $ + , Q.testProperty "to_integer . to_word256 ~ id (for nonnegative input)" $ Q.withMaxSuccess 1000 to_integer_inverts_to_word256 ]