on master help sign in
GHC 7 compatibility for tests
7fd385bJasper Van der Jeugt
tests/Makefile+5−1
@@ -1,4 +1,5 @@
1version := $(shell awk '/^version:/{print $$2}' ../text.cabal)
1version := $(shell awk '/^version:/{print $$2}' ../text.cabal)
2+ghc-major-version := $(shell ghc --numeric-version | sed 's/\..*//')
2ghc := ghc
3ghc := ghc
3ghc-opt-flags = -O0
4ghc-opt-flags = -O0
4ghc-base-flags := -funbox-strict-fields -hide-all-packages \
5ghc-base-flags := -funbox-strict-fields -hide-all-packages \
@@ -6,9 +7,12 @@ ghc-base-flags := -funbox-strict-fields -hide-all-packages \
6 -package criterion -package deepseq -DASSERTS -DHAVE_DEEPSEQ \
7 -package criterion -package deepseq -DASSERTS -DHAVE_DEEPSEQ \
7 -package bytestring -ignore-package text \
8 -package bytestring -ignore-package text \
8 -fno-ignore-asserts
9 -fno-ignore-asserts
10+ifeq ($(ghc-major-version),7)
11+ ghc-base-flags += -rtsopts
12+endif
9ghc-test-flags := -package QuickCheck -package test-framework -package deepseq \
13ghc-test-flags := -package QuickCheck -package test-framework -package deepseq \
10 -package test-framework-quickcheck2 -package test-framework-hunit \
14 -package test-framework-quickcheck2 -package test-framework-hunit \
11− -package HUnit
15+ -package HUnit -package directory
12ghc-base-flags += -Wall -fno-warn-orphans -fno-warn-missing-signatures
16ghc-base-flags += -Wall -fno-warn-orphans -fno-warn-missing-signatures
13ghc-flags := $(ghc-base-flags) -i../dist/build -package-name text-$(version)
17ghc-flags := $(ghc-base-flags) -i../dist/build -package-name text-$(version)
14ghc-hpc-flags := $(ghc-base-flags) -fhpc -fno-ignore-asserts -odir hpcdir \
18ghc-hpc-flags := $(ghc-base-flags) -fhpc -fno-ignore-asserts -odir hpcdir \
tests/Properties.hs+6−3
@@ -1,5 +1,5 @@
1{-# LANGUAGE BangPatterns, FlexibleInstances, OverloadedStrings,
1{-# LANGUAGE BangPatterns, FlexibleInstances, OverloadedStrings,
2− ScopedTypeVariables, TypeSynonymInstances #-}
2+ ScopedTypeVariables, TypeSynonymInstances, CPP #-}
3{-# OPTIONS_GHC -fno-enable-rewrite-rules #-}
3{-# OPTIONS_GHC -fno-enable-rewrite-rules #-}
4
4
5import Test.QuickCheck
5import Test.QuickCheck
@@ -734,6 +734,8 @@ instance Arbitrary Encoding where
734
734
735windowsNewlineMode = NewlineMode { inputNL = CRLF, outputNL = CRLF }
735windowsNewlineMode = NewlineMode { inputNL = CRLF, outputNL = CRLF }
736
736
737+-- Newline and NewlineMode have standard Show instance from GHC 7 onwards
738+#if __GLASGOW_HASKELL__ < 700
737instance Show Newline where
739instance Show Newline where
738 show CRLF = "CRLF"
740 show CRLF = "CRLF"
739 show LF = "LF"
741 show LF = "LF"
@@ -741,6 +743,7 @@ instance Show Newline where
741instance Show NewlineMode where
743instance Show NewlineMode where
742 show (NewlineMode i o) = "NewlineMode { inputNL = " ++ show i ++
744 show (NewlineMode i o) = "NewlineMode { inputNL = " ++ show i ++
743 ", outputNL = " ++ show o ++ " }"
745 ", outputNL = " ++ show o ++ " }"
746+# endif
744
747
745instance Arbitrary NewlineMode where
748instance Arbitrary NewlineMode where
746 arbitrary = oneof . map return $
749 arbitrary = oneof . map return $
@@ -770,13 +773,13 @@ write_read unline filt writer reader (E _ enc) nl buf ts =
770 monadicIO $ assert . (==t) =<< run act
773 monadicIO $ assert . (==t) =<< run act
771 where t = unline . map (filt (not . (`elem` "\r\n"))) $ ts
774 where t = unline . map (filt (not . (`elem` "\r\n"))) $ ts
772 act = withTempFile $ \path h -> do
775 act = withTempFile $ \path h -> do
773− hSetEncoding h enc
776+ -- hSetEncoding h enc
774 hSetNewlineMode h nl
777 hSetNewlineMode h nl
775 hSetBuffering h buf
778 hSetBuffering h buf
776 () <- writer h t
779 () <- writer h t
777 hClose h
780 hClose h
778 bracket (openFile path ReadMode) hClose $ \h' -> do
781 bracket (openFile path ReadMode) hClose $ \h' -> do
779− hSetEncoding h' enc
782+ -- hSetEncoding h' enc
780 hSetNewlineMode h' nl
783 hSetNewlineMode h' nl
781 hSetBuffering h' buf
784 hSetBuffering h' buf
782 r <- reader h'
785 r <- reader h'