Updates for compiling with ghc 7.

We now use a CPP trick to have compatible quasiquotes that
work in both GHC 6.12 and 7.
This commit is contained in:
John MacFarlane 2011-01-26 09:09:32 -08:00
parent 422bba202e
commit c5384a33c0
3 changed files with 13 additions and 7 deletions

View file

@ -330,7 +330,11 @@ Executable test-pandoc
Hs-Source-Dirs: tests, src Hs-Source-Dirs: tests, src
Main-Is: test-pandoc.hs Main-Is: test-pandoc.hs
if flag(highlighting) if flag(highlighting)
cpp-options: -D_HIGHLIGHTING cpp-options: -D_HIGHLIGHTING
if impl(ghc >= 7)
cpp-options: -D_LIT=lit
else
cpp-options: -D_LIT=$lit
if !flag(tests) if !flag(tests)
Buildable: False Buildable: False
else else
@ -342,9 +346,9 @@ Executable test-pandoc
Build-Depends: base >= 4 && < 5, Diff, test-framework >= 0.3 && < 0.4, Build-Depends: base >= 4 && < 5, Diff, test-framework >= 0.3 && < 0.4,
test-framework-hunit >= 0.2 && < 0.3, test-framework-hunit >= 0.2 && < 0.3,
test-framework-quickcheck2 >= 0.2.9 && < 0.3, test-framework-quickcheck2 >= 0.2.9 && < 0.3,
QuickCheck == 2.4.*, QuickCheck >= 2.4 && < 2.6,
HUnit >= 1.2 && < 1.3, HUnit >= 1.2 && < 1.3,
template-haskell == 2.4.*, template-haskell >= 2.4 && < 2.6,
ansi-terminal == 0.5.* ansi-terminal == 0.5.*
Other-Modules: Tests.Old Other-Modules: Tests.Old
Tests.Helpers Tests.Helpers

View file

@ -20,15 +20,17 @@ import Test.HUnit (assertBool)
import Text.Pandoc.Shared (normalize, defaultWriterOptions, import Text.Pandoc.Shared (normalize, defaultWriterOptions,
WriterOptions(..), removeTrailingSpace) WriterOptions(..), removeTrailingSpace)
import Text.Pandoc.Writers.Native (writeNative) import Text.Pandoc.Writers.Native (writeNative)
import Language.Haskell.TH.Quote import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Haskell.TH.Syntax (Q, runIO) import Language.Haskell.TH.Syntax (Q, runIO)
import qualified Test.QuickCheck.Property as QP import qualified Test.QuickCheck.Property as QP
import System.Console.ANSI import System.Console.ANSI
import Data.Algorithm.Diff import Data.Algorithm.Diff
lit :: QuasiQuoter lit :: QuasiQuoter
lit = QuasiQuoter ((\a -> let b = rnl a in [|b|]) . filter (/= '\r')) $ lit = QuasiQuoter {
error "Cannot use lit as a pattern" quoteExp = (\a -> let b = rnl a in [|b|]) . filter (/= '\r')
, quotePat = error "Cannot use lit as a pattern"
}
where rnl ('\n':xs) = xs where rnl ('\n':xs) = xs
rnl xs = xs rnl xs = xs

View file

@ -52,7 +52,7 @@ tests = [ testGroup "inline code"
bulletList [plain (text "top") bulletList [plain (text "top")
,bulletList [plain (text "next") ,bulletList [plain (text "next")
,bulletList [plain (text "bot")]]] ,bulletList [plain (text "bot")]]]
=?> [$lit| =?> [_LIT|
\startitemize \startitemize
\item \item
top top