on master help sign in
Add t_write_hGetContents
20edcdaBryan O'Sullivan
tests/Properties.hs+9−4
@@ -581,14 +581,18 @@ t_builderAssociative s1 s2 s3 = TB.toLazyText (b1 `mappend` (b2 `mappend` b3)) =
581
581
582-- Input and output.
582-- Input and output.
583
583
584−t_write_read (NotEmpty t) = monadicIO $ do
584+t_write_read t = monadicIO $ assert . (==t) =<< run act
585− r <- run act
586− assert (r == t)
587 where act = withTempFile $ \path h -> do
585 where act = withTempFile $ \path h -> do
588 T.hPutStr h t
586 T.hPutStr h t
589 hClose h
587 hClose h
590 T.readFile path
588 T.readFile path
591
589
590+t_write_hGetContents t = monadicIO $ assert . (==t) =<< run act
591+ where act = withTempFile $ \_path h -> do
592+ T.hPutStr h t
593+ hSeek h AbsoluteSeek 0
594+ T.hGetContents h
595+
592-- Low-level.
596-- Low-level.
593
597
594t_dropWord16 m t = dropWord16 m t `T.isSuffixOf` t
598t_dropWord16 m t = dropWord16 m t `T.isSuffixOf` t
@@ -981,7 +985,8 @@ tests = [
981 ],
985 ],
982
986
983 testGroup "io" [
987 testGroup "io" [
984− testProperty "t_write_read" t_write_read
988+ testProperty "t_write_read" t_write_read,
989+ testProperty "t_write_hGetContents" t_write_hGetContents
985 ],
990 ],
986
991
987 testGroup "lowlevel" [
992 testGroup "lowlevel" [