@@ -608,8 +608,21 @@ instance Arbitrary NewlineMode where
608 [ noNewlineTranslation, universalNewlineMode, nativeNewlineMode,
608 [ noNewlineTranslation, universalNewlineMode, nativeNewlineMode,
609 windowsNewlineMode ]
609 windowsNewlineMode ]
611+-- This test harness is complex! What property are we checking?
613+-- Reading after writing a multi-line file should give the same
614+-- results as were written.
616+-- What do we vary while checking this property?
617+-- * The lines themselves, scrubbed to contain neither CR nor LF. (By
618+-- working with a list of lines, we ensure that the data will
619+-- sometimes contain line endings.)
621+-- * Newline translation mode.
622+write_read unline filt writer reader (E _ e) m ts =
611−write_read writer reader (E _ e) m t = monadicIO $ assert . (==t) =<< run act
623+ monadicIO $ assert . (==t) =<< run act
624+ where t = unline . map (filt (not . (`elem` "\r\n"))) $ ts
612− where act = withTempFile $ \path h -> do
625+ act = withTempFile $ \path h -> do
613 hSetEncoding h e
626 hSetEncoding h e
614 hSetNewlineMode h m
627 hSetNewlineMode h m
615 () <- writer h t
628 () <- writer h t
@@ -620,9 +633,13 @@ write_read writer reader (E _ e) m t = monadicIO $ assert . (==t) =<< run act
620 r <- reader h'
633 r <- reader h'
621 r `deepseq` return r
634 r `deepseq` return r
623−t_write_read = write_read T.hPutStr T.hGetContents
636+t_write_read = write_read T.unlines T.filter T.hPutStr T.hGetContents
637+tl_write_read = write_read TL.unlines TL.filter TL.hPutStr TL.hGetContents
625−tl_write_read = write_read TL.hPutStr TL.hGetContents
639+t_write_read_line e m t = write_read head T.filter T.hPutStrLn
641+tl_write_read_line e m t = write_read head TL.filter TL.hPutStrLn
627-- Low-level.
644-- Low-level.
@@ -1017,7 +1034,9 @@ tests = [
1018 testGroup "input-output" [
1035 testGroup "input-output" [
1019 testProperty "t_write_read" t_write_read,
1036 testProperty "t_write_read" t_write_read,
1020− testProperty "tl_write_read" tl_write_read
1037+ testProperty "tl_write_read" tl_write_read,
1038+ testProperty "t_write_read_line" t_write_read_line,
1039+ testProperty "tl_write_read_line" tl_write_read_line
1023 testGroup "lowlevel" [
1042 testGroup "lowlevel" [