aboutsummaryrefslogtreecommitdiff
path: root/tests/unit-tests
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-07-19 16:28:45 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-07-19 16:49:32 +0100
commit6e8bc1dca77bbbc5743f63a2e8ea5b1eab0ed80c (patch)
tree5f4ad32677af3e2b95e468e5bcab94c38e5d88e1 /tests/unit-tests
parent105f31e1b5b1428ae27590893740017327d322ff (diff)
parent2a931d32cfdbd20d4da0cff6415a3aaf47823938 (diff)
Forward port changes from stable.
Diffstat (limited to 'tests/unit-tests')
-rw-r--r--tests/unit-tests/.ghci1
-rw-r--r--tests/unit-tests/parsetests.hs15
-rwxr-xr-x[-rw-r--r--]tests/unit-tests/runparsetests.sh20
3 files changed, 22 insertions, 14 deletions
diff --git a/tests/unit-tests/.ghci b/tests/unit-tests/.ghci
new file mode 100644
index 00000000..10563664
--- /dev/null
+++ b/tests/unit-tests/.ghci
@@ -0,0 +1 @@
+:set -i../../src -i../../dist/build/autogen -i../../dist/build/haddock/haddock-tmp/ -packageghc -optP-include -optP../../dist/build/autogen/cabal_macros.h -XCPP -XDeriveDataTypeable -XScopedTypeVariables -XMagicHash
diff --git a/tests/unit-tests/parsetests.hs b/tests/unit-tests/parsetests.hs
index e0645401..7180a79e 100644
--- a/tests/unit-tests/parsetests.hs
+++ b/tests/unit-tests/parsetests.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE StandaloneDeriving, FlexibleInstances, UndecidableInstances, IncoherentInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
module Main (main) where
import Test.HUnit
@@ -6,9 +8,13 @@ import DynFlags (defaultDynFlags)
import Haddock.Lex (tokenise)
import Haddock.Parse (parseParas)
import Haddock.Types
+import Outputable
-instance Show RdrName where
- show x = "RdrName"
+instance Outputable a => Show a where
+ show = showSDoc . ppr
+
+deriving instance Show a => Show (Doc a)
+deriving instance Eq a =>Eq (Doc a)
data ParseTest = ParseTest {
input :: String
@@ -50,13 +56,14 @@ tests = [
]
+main :: IO ()
main = do
_ <- runTestTT $ TestList $ map toTestCase tests
return ();
where
toTestCase :: ParseTest -> Test
- toTestCase (ParseTest input result) = TestCase $ assertEqual input result (parse input)
+ toTestCase (ParseTest s r) = TestCase $ assertEqual s r (parse s)
parse :: String -> Maybe (Doc RdrName)
- parse input = parseParas $ tokenise defaultDynFlags input (0,0)
+ parse s = parseParas $ tokenise (defaultDynFlags undefined) s (0,0)
diff --git a/tests/unit-tests/runparsetests.sh b/tests/unit-tests/runparsetests.sh
index 1dae69c2..ead0ccf5 100644..100755
--- a/tests/unit-tests/runparsetests.sh
+++ b/tests/unit-tests/runparsetests.sh
@@ -1,15 +1,15 @@
#!/bin/sh
cd `dirname $0`
-runhaskell -hide-all-packages -cpp \
- -packagecontainers \
- -packagearray \
- -packagebase \
+runhaskell \
+ -i../../src \
+ -i../../dist/build/autogen \
+ -i../../dist/build/haddock/haddock-tmp/ \
-packageghc \
- -packagexhtml \
- -packageghc-paths \
- -packageHUnit \
- -i../../dist/build/ \
- -i../../src/ \
- -optP-include -optP../../dist/build/autogen/cabal_macros.h \
+ -optP-include \
+ -optP../../dist/build/autogen/cabal_macros.h \
+ -XCPP \
+ -XDeriveDataTypeable \
+ -XScopedTypeVariables \
+ -XMagicHash \
parsetests.hs