From 0556ec330cdc96eb751fbf1a2b5eb57fd75ac906 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 13 Mar 2013 13:37:17 +0900 Subject: [PATCH] test for fast (not TH). --- Debug.hs | 2 +- ghc-mod.cabal | 1 + test/DebugSpec.hs | 23 +++++++++++++++++++++++ test/data/Bar.hs | 5 +++++ test/data/Foo.hs | 5 +++++ test/data/Main.hs | 3 +++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/DebugSpec.hs create mode 100644 test/data/Bar.hs create mode 100644 test/data/Foo.hs create mode 100644 test/data/Main.hs diff --git a/Debug.hs b/Debug.hs index 2bf8626..b7280f6 100644 --- a/Debug.hs +++ b/Debug.hs @@ -1,4 +1,4 @@ -module Debug (debugInfo) where +module Debug (debugInfo, debug) where import CabalApi import Control.Applicative diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 8328e9c..ce093a1 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -80,6 +80,7 @@ Test-Suite spec BrowseSpec CabalApiSpec CheckSpec + DebugSpec FlagSpec InfoSpec LangSpec diff --git a/test/DebugSpec.hs b/test/DebugSpec.hs new file mode 100644 index 0000000..143ac8c --- /dev/null +++ b/test/DebugSpec.hs @@ -0,0 +1,23 @@ +module DebugSpec where + +import CabalApi +import Cradle +import Debug +import Expectation +import Test.Hspec +import Types + +checkFast :: String -> String -> IO () +checkFast file ans = withDirectory_ "test/data" $ do + (strVer,_) <- getGHCVersion + cradle <- findCradle Nothing strVer + res <- debug defaultOptions cradle strVer file + res `shouldContain` ans + +spec :: Spec +spec = do + describe "debug" $ do + it "can check TH" $ do + checkFast "Main.hs" "Fast check: No" + checkFast "Foo.hs" "Fast check: Yes" + checkFast "Bar.hs" "Fast check: No" diff --git a/test/data/Bar.hs b/test/data/Bar.hs new file mode 100644 index 0000000..d38aaaf --- /dev/null +++ b/test/data/Bar.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} +module Bar (bar) where +import Foo (foo) + +bar = $foo ++ "bar" diff --git a/test/data/Foo.hs b/test/data/Foo.hs new file mode 100644 index 0000000..225c640 --- /dev/null +++ b/test/data/Foo.hs @@ -0,0 +1,5 @@ +module Foo (foo) where +import Language.Haskell.TH + +foo :: ExpQ +foo = stringE "foo" diff --git a/test/data/Main.hs b/test/data/Main.hs new file mode 100644 index 0000000..0fd5838 --- /dev/null +++ b/test/data/Main.hs @@ -0,0 +1,3 @@ +import Bar (bar) + +main = putStrLn bar