ghc-mod/test/BrowseSpec.hs

35 lines
1.2 KiB
Haskell
Raw Normal View History

2013-02-12 05:18:19 +00:00
module BrowseSpec where
import Control.Applicative
2013-05-20 02:29:44 +00:00
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Cradle
2013-05-20 02:29:44 +00:00
import Test.Hspec
2013-02-12 05:18:19 +00:00
2014-05-10 13:10:34 +00:00
import TestUtils
import Dir
2013-02-12 05:18:19 +00:00
spec :: Spec
spec = do
2014-05-10 13:10:34 +00:00
describe "browse" $ do
2013-02-12 05:18:19 +00:00
it "lists up symbols in the module" $ do
2014-05-10 13:10:34 +00:00
syms <- runD $ lines <$> browse "Data.Map"
syms `shouldContain` ["differenceWithKey"]
2013-03-01 00:46:17 +00:00
2014-05-10 13:10:34 +00:00
describe "browse -d" $ do
2013-03-01 00:46:17 +00:00
it "lists up symbols with type info in the module" $ do
2014-05-10 13:10:34 +00:00
syms <- run defaultOptions { detailed = True }
$ lines <$> browse "Data.Either"
syms `shouldContain` ["either :: (a -> c) -> (b -> c) -> Either a b -> c"]
it "lists up data constructors with type info in the module" $ do
cradle <- findCradle
2014-05-10 13:10:34 +00:00
syms <- run defaultOptions { detailed = True}
$ lines <$> browse "Data.Either"
syms `shouldContain` ["Left :: a -> Either a b"]
2014-05-10 13:10:34 +00:00
describe "browse local" $ do
it "lists symbols in a local module" $ do
withDirectory_ "test/data" $ do
2014-05-10 13:10:34 +00:00
syms <- runID $ lines <$> browse "Baz"
syms `shouldContain` ["baz"]