@@ -626,6 +626,13 @@ instance Arbitrary NewlineMode where
626626 [ noNewlineTranslation, universalNewlineMode, nativeNewlineMode,
627627 windowsNewlineMode ]
628628
629+instance Arbitrary BufferMode where
630+ arbitrary = oneof [ return NoBuffering,
631+ return LineBuffering,
632+ return (BlockBuffering Nothing),
633+ (BlockBuffering . Just . fromIntegral) `fmap` arb16 ]
634+ where arb16 = arbitrary :: Gen Word16
635+
629636-- This test harness is complex! What property are we checking?
630637--
631638-- Reading after writing a multi-line file should give the same
@@ -637,17 +644,20 @@ instance Arbitrary NewlineMode where
637644-- sometimes contain line endings.)
638645-- * Encoding.
639646-- * Newline translation mode.
640−write_read unline filt writer reader (E _ e) m ts =
647+-- * Buffering.
648+write_read unline filt writer reader (E _ enc) nl buf ts =
641649 monadicIO $ assert . (==t) =<< run act
642650 where t = unline . map (filt (not . (`elem` "\r\n"))) $ ts
643651 act = withTempFile $ \path h -> do
644− hSetEncoding h e
645− hSetNewlineMode h m
652+ hSetEncoding h enc
653+ hSetNewlineMode h nl
654+ hSetBuffering h buf
646655 () <- writer h t
647656 hClose h
648657 bracket (openFile path ReadMode) hClose $ \h' -> do
649− hSetEncoding h' e
650− hSetNewlineMode h' m
658+ hSetEncoding h' enc
659+ hSetNewlineMode h' nl
660+ hSetBuffering h' buf
651661 r <- reader h'
652662 r `deepseq` return r
653663
@@ -660,10 +670,10 @@ tl_put_get = write_read TL.unlines TL.filter put get
660670t_write_read = write_read T.unlines T.filter T.hPutStr T.hGetContents
661671tl_write_read = write_read TL.unlines TL.filter TL.hPutStr TL.hGetContents
662672
663−t_write_read_line e m t = write_read head T.filter T.hPutStrLn
664− T.hGetLine e m [t]
665−tl_write_read_line e m t = write_read head TL.filter TL.hPutStrLn
666− TL.hGetLine e m [t]
673+t_write_read_line e m b t = write_read head T.filter T.hPutStrLn
674+ T.hGetLine e m b [t]
675+tl_write_read_line e m b t = write_read head TL.filter TL.hPutStrLn
676+ TL.hGetLine e m b [t]
667677
668678-- Low-level.
669679