on master help sign in
GHC 7 compatibility for tests
commit7fd385bb0be693f94a56a78b40d93ff3e5fb916e authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 13 May 2011, 20:23 (15 years ago) parent795a66b
2 files changed+11−4
tests/Makefile+5−1 tests/Properties.hs+6−3
tests/Makefile+5−1
@@ -1,4 +1,5 @@
11version := $(shell awk '/^version:/{print $$2}' ../text.cabal)
2+ghc-major-version := $(shell ghc --numeric-version | sed 's/\..*//')
23ghc := ghc
34ghc-opt-flags = -O0
45ghc-base-flags := -funbox-strict-fields -hide-all-packages \
@@ -6,9 +7,12 @@ ghc-base-flags := -funbox-strict-fields -hide-all-packages \
67 -package criterion -package deepseq -DASSERTS -DHAVE_DEEPSEQ \
78 -package bytestring -ignore-package text \
89 -fno-ignore-asserts
10+ifeq ($(ghc-major-version),7)
11+ ghc-base-flags += -rtsopts
12+endif
913ghc-test-flags := -package QuickCheck -package test-framework -package deepseq \
1014 -package test-framework-quickcheck2 -package test-framework-hunit \
11− -package HUnit
15+ -package HUnit -package directory
1216ghc-base-flags += -Wall -fno-warn-orphans -fno-warn-missing-signatures
1317ghc-flags := $(ghc-base-flags) -i../dist/build -package-name text-$(version)
1418ghc-hpc-flags := $(ghc-base-flags) -fhpc -fno-ignore-asserts -odir hpcdir \
tests/Properties.hs+6−3
@@ -1,5 +1,5 @@
11{-# LANGUAGE BangPatterns, FlexibleInstances, OverloadedStrings,
2− ScopedTypeVariables, TypeSynonymInstances #-}
2+ ScopedTypeVariables, TypeSynonymInstances, CPP #-}
33{-# OPTIONS_GHC -fno-enable-rewrite-rules #-}
44
55import Test.QuickCheck
@@ -734,6 +734,8 @@ instance Arbitrary Encoding where
734734
735735windowsNewlineMode = NewlineMode { inputNL = CRLF, outputNL = CRLF }
736736
737+-- Newline and NewlineMode have standard Show instance from GHC 7 onwards
738+#if __GLASGOW_HASKELL__ < 700
737739instance Show Newline where
738740 show CRLF = "CRLF"
739741 show LF = "LF"
@@ -741,6 +743,7 @@ instance Show Newline where
741743instance Show NewlineMode where
742744 show (NewlineMode i o) = "NewlineMode { inputNL = " ++ show i ++
743745 ", outputNL = " ++ show o ++ " }"
746+# endif
744747
745748instance Arbitrary NewlineMode where
746749 arbitrary = oneof . map return $
@@ -770,13 +773,13 @@ write_read unline filt writer reader (E _ enc) nl buf ts =
770773 monadicIO $ assert . (==t) =<< run act
771774 where t = unline . map (filt (not . (`elem` "\r\n"))) $ ts
772775 act = withTempFile $ \path h -> do
773− hSetEncoding h enc
776+ -- hSetEncoding h enc
774777 hSetNewlineMode h nl
775778 hSetBuffering h buf
776779 () <- writer h t
777780 hClose h
778781 bracket (openFile path ReadMode) hClose $ \h' -> do
779− hSetEncoding h' enc
782+ -- hSetEncoding h' enc
780783 hSetNewlineMode h' nl
781784 hSetBuffering h' buf
782785 r <- reader h'