@@ -16,6 +16,7 @@ import Text.Show.Functions ()
1616import Control.Arrow ((***), second)
1717import Control.Exception (catch)
1818import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isUpper, ord)
19+import Data.Int (Int8)
1920import Data.Monoid (Monoid(..))
2021import Data.String (fromString)
2122import Data.Text.Encoding.Error
@@ -39,6 +40,7 @@ import qualified Data.Text.Fusion.Common as S
3940import qualified Data.Text.IO as T
4041import qualified Data.Text.Lazy as TL
4142import qualified Data.Text.Lazy.Builder as TB
43+import qualified Data.Text.Lazy.Builder.Int as TB
4244import qualified Data.Text.Lazy.Encoding as EL
4345import qualified Data.Text.Lazy.Fusion as SL
4446import qualified Data.Text.Lazy.IO as TL
@@ -610,17 +612,24 @@ shiftR_Word32 = shiftR :: Word32 -> Property
610612
611613-- Builder.
612614
613−t_builderSingleton = id `eqP`
614− (unpackS . TB.toLazyText . mconcat . map TB.singleton)
615−t_builderFromText = L.concat `eq` (unpackS . TB.toLazyText . mconcat .
615+tb_singleton = id `eqP`
616+ (unpackS . TB.toLazyText . mconcat . map TB.singleton)
617+tb_fromText = L.concat `eq` (unpackS . TB.toLazyText . mconcat .
616618 map (TB.fromText . packS))
617−t_builderAssociative s1 s2 s3 =
619+tb_associative s1 s2 s3 =
618620 TB.toLazyText (b1 `mappend` (b2 `mappend` b3)) ==
619621 TB.toLazyText ((b1 `mappend` b2) `mappend` b3)
620622 where b1 = TB.fromText (packS s1)
621623 b2 = TB.fromText (packS s2)
622624 b3 = TB.fromText (packS s3)
623625
626+-- Numeric builder stuff.
627+
628+tb_decimal :: (Integral a, Show a) => a -> Bool
629+tb_decimal = (TB.toLazyText . TB.decimal) `eq` (TL.pack . show)
630+
631+tb_decimal_int8 (a::Int8) = tb_decimal a
632+
624633-- Reading.
625634
626635t_decimal (n::Int) s =
@@ -691,7 +700,7 @@ s_filter_eq s = S.filter p t == S.streamList (filter p s)
691700-- themselves.
692701shorten :: Int -> S.Stream a -> S.Stream a
693702shorten n t@(S.Stream arr off len)
694− | n > 0 = S.Stream arr off (smaller (exactSize n) len)
703+ | n > 0 = S.Stream arr off (smaller (exactSize n) len)
695704 | otherwise = t
696705
697706tests :: Test
@@ -1080,9 +1089,10 @@ tests =
10801089 ],
10811090
10821091 testGroup "builder" [
1083− testProperty "t_builderSingleton" t_builderSingleton,
1084− testProperty "t_builderFromText" t_builderFromText,
1085− testProperty "t_builderAssociative" t_builderAssociative
1092+ testProperty "tb_associative" tb_associative,
1093+ testProperty "tb_decimal_int8" tb_decimal_int8,
1094+ testProperty "tb_fromText" tb_fromText,
1095+ testProperty "tb_singleton" tb_singleton
10861096 ],
10871097
10881098 testGroup "read" [