From 6752a8edcf58bfc82463fa2eb857d5718907d42b Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 13 Feb 2013 16:22:07 +0900 Subject: [PATCH] test for Info. --- ghc-mod.cabal | 1 + test/InfoSpec.hs | 14 ++++++++++++++ test/data/ghc-mod-check/Data/Foo.hs | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 test/InfoSpec.hs diff --git a/ghc-mod.cabal b/ghc-mod.cabal index acc74b9..4383303 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -72,6 +72,7 @@ Test-Suite spec CabalApiSpec CheckSpec FlagSpec + InfoSpec LangSpec LintSpec ListSpec diff --git a/test/InfoSpec.hs b/test/InfoSpec.hs new file mode 100644 index 0000000..1926938 --- /dev/null +++ b/test/InfoSpec.hs @@ -0,0 +1,14 @@ +module InfoSpec where + +import Test.Hspec +import Expectation +import Info +import Types + +spec :: Spec +spec = do + describe "typeExpr" $ do + it "shows types of the expression and its outers" $ do + withDirectory "test/data/ghc-mod-check" $ do + res <- typeExpr defaultOptions "Data.Foo" 9 5 "Data/Foo.hs" + res `shouldBe` "9 5 11 40 \"Int -> a -> a -> a\"\n7 1 11 40 \"Int -> Integer\"\n" diff --git a/test/data/ghc-mod-check/Data/Foo.hs b/test/data/ghc-mod-check/Data/Foo.hs index eb18003..bbb369e 100644 --- a/test/data/ghc-mod-check/Data/Foo.hs +++ b/test/data/ghc-mod-check/Data/Foo.hs @@ -2,3 +2,10 @@ module Data.Foo where foo :: Int foo = undefined + +fibonacci :: Int -> Integer +fibonacci n = fib 1 0 1 + where + fib m x y + | n == m = y + | otherwise = fib (m+1) y (x + y)