on master help sign in
Test builder rendering of numbers in all cases
0c71074Bryan O'Sullivan
tests/Tests/Properties.hs+53−3
@@ -16,7 +16,7 @@ import Text.Show.Functions ()
16import Control.Arrow ((***), second)
16import Control.Arrow ((***), second)
17import Control.Exception (catch)
17import Control.Exception (catch)
18import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isUpper, ord)
18import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isUpper, ord)
19−import Data.Int (Int8)
19+import Data.Int (Int8, Int16, Int32, Int64)
20import Data.Monoid (Monoid(..))
20import Data.Monoid (Monoid(..))
21import Data.String (fromString)
21import Data.String (fromString)
22import Data.Text.Encoding.Error
22import Data.Text.Encoding.Error
@@ -25,7 +25,7 @@ import Data.Text.Fusion.Size
25import Data.Text.Lazy.Read as TL
25import Data.Text.Lazy.Read as TL
26import Data.Text.Read as T
26import Data.Text.Read as T
27import Data.Text.Search (indices)
27import Data.Text.Search (indices)
28−import Data.Word (Word8, Word16, Word32)
28+import Data.Word (Word, Word8, Word16, Word32, Word64)
29import Numeric (showHex)
29import Numeric (showHex)
30import Prelude hiding (catch, replicate)
30import Prelude hiding (catch, replicate)
31import Test.Framework (Test, testGroup)
31import Test.Framework (Test, testGroup)
@@ -628,7 +628,32 @@ tb_associative s1 s2 s3 =
628tb_decimal :: (Integral a, Show a) => a -> Bool
628tb_decimal :: (Integral a, Show a) => a -> Bool
629tb_decimal = (TB.toLazyText . TB.decimal) `eq` (TL.pack . show)
629tb_decimal = (TB.toLazyText . TB.decimal) `eq` (TL.pack . show)
630
630
631+tb_decimal_integer (a::Integer) = tb_decimal a
632+tb_decimal_int (a::Int) = tb_decimal a
631tb_decimal_int8 (a::Int8) = tb_decimal a
633tb_decimal_int8 (a::Int8) = tb_decimal a
634+tb_decimal_int16 (a::Int16) = tb_decimal a
635+tb_decimal_int32 (a::Int32) = tb_decimal a
636+tb_decimal_int64 (a::Int64) = tb_decimal a
637+tb_decimal_word (a::Word) = tb_decimal a
638+tb_decimal_word8 (a::Word8) = tb_decimal a
639+tb_decimal_word16 (a::Word16) = tb_decimal a
640+tb_decimal_word32 (a::Word32) = tb_decimal a
641+tb_decimal_word64 (a::Word64) = tb_decimal a
642+
643+tb_hex :: (Integral a, Show a) => a -> Bool
644+tb_hex = (TB.toLazyText . TB.hexadecimal) `eq` (TL.pack . flip showHex "")
645+
646+tb_hexadecimal_integer (a::Integer) = tb_hex a
647+tb_hexadecimal_int (a::Int) = tb_hex a
648+tb_hexadecimal_int8 (a::Int8) = tb_hex a
649+tb_hexadecimal_int16 (a::Int16) = tb_hex a
650+tb_hexadecimal_int32 (a::Int32) = tb_hex a
651+tb_hexadecimal_int64 (a::Int64) = tb_hex a
652+tb_hexadecimal_word (a::Word) = tb_hex a
653+tb_hexadecimal_word8 (a::Word8) = tb_hex a
654+tb_hexadecimal_word16 (a::Word16) = tb_hex a
655+tb_hexadecimal_word32 (a::Word32) = tb_hex a
656+tb_hexadecimal_word64 (a::Word64) = tb_hex a
632
657
633-- Reading.
658-- Reading.
634
659
@@ -1090,7 +1115,32 @@ tests =
1090
1115
1091 testGroup "builder" [
1116 testGroup "builder" [
1092 testProperty "tb_associative" tb_associative,
1117 testProperty "tb_associative" tb_associative,
1118+ testGroup "decimal" [
1119+ testProperty "tb_decimal_int" tb_decimal_int,
1093− testProperty "tb_decimal_int8" tb_decimal_int8,
1120+ testProperty "tb_decimal_int8" tb_decimal_int8,
1121+ testProperty "tb_decimal_int16" tb_decimal_int16,
1122+ testProperty "tb_decimal_int32" tb_decimal_int32,
1123+ testProperty "tb_decimal_int64" tb_decimal_int64,
1124+ testProperty "tb_decimal_integer" tb_decimal_integer,
1125+ testProperty "tb_decimal_word" tb_decimal_word,
1126+ testProperty "tb_decimal_word8" tb_decimal_word8,
1127+ testProperty "tb_decimal_word16" tb_decimal_word16,
1128+ testProperty "tb_decimal_word32" tb_decimal_word32,
1129+ testProperty "tb_decimal_word64" tb_decimal_word64
1130+ ],
1131+ testGroup "hexadecimal" [
1132+ testProperty "tb_hexadecimal_int" tb_hexadecimal_int,
1133+ testProperty "tb_hexadecimal_int8" tb_hexadecimal_int8,
1134+ testProperty "tb_hexadecimal_int16" tb_hexadecimal_int16,
1135+ testProperty "tb_hexadecimal_int32" tb_hexadecimal_int32,
1136+ testProperty "tb_hexadecimal_int64" tb_hexadecimal_int64,
1137+ testProperty "tb_hexadecimal_integer" tb_hexadecimal_integer,
1138+ testProperty "tb_hexadecimal_word" tb_hexadecimal_word,
1139+ testProperty "tb_hexadecimal_word8" tb_hexadecimal_word8,
1140+ testProperty "tb_hexadecimal_word16" tb_hexadecimal_word16,
1141+ testProperty "tb_hexadecimal_word32" tb_hexadecimal_word32,
1142+ testProperty "tb_hexadecimal_word64" tb_hexadecimal_word64
1143+ ],
1094 testProperty "tb_fromText" tb_fromText,
1144 testProperty "tb_fromText" tb_fromText,
1095 testProperty "tb_singleton" tb_singleton
1145 testProperty "tb_singleton" tb_singleton
1096 ],
1146 ],