2013-02-12 14:18:19 +09:00
|
|
|
module BrowseSpec where
|
|
|
|
|
|
|
|
|
|
import Control.Applicative
|
2013-05-20 11:29:44 +09:00
|
|
|
import Language.Haskell.GhcMod
|
|
|
|
|
import Test.Hspec
|
2015-08-31 08:01:20 +02:00
|
|
|
import Prelude
|
2013-02-12 14:18:19 +09:00
|
|
|
|
2014-05-10 15:10:34 +02:00
|
|
|
import TestUtils
|
2013-11-20 08:57:45 +04:00
|
|
|
import Dir
|
|
|
|
|
|
2013-02-12 14:18:19 +09:00
|
|
|
spec :: Spec
|
|
|
|
|
spec = do
|
2014-07-11 03:10:37 +02:00
|
|
|
describe "browse Data.Map" $ do
|
|
|
|
|
it "contains at least `differenceWithKey'" $ do
|
2014-05-10 15:10:34 +02:00
|
|
|
syms <- runD $ lines <$> browse "Data.Map"
|
2013-09-03 11:44:59 +09:00
|
|
|
syms `shouldContain` ["differenceWithKey"]
|
2013-03-01 09:46:17 +09:00
|
|
|
|
2014-07-11 03:10:37 +02:00
|
|
|
describe "browse -d Data.Either" $ do
|
|
|
|
|
it "contains functions (e.g. `either') including their type signature" $ do
|
2015-09-01 10:27:12 +02:00
|
|
|
syms <- run defaultOptions { optDetailed = True }
|
2014-05-10 15:10:34 +02:00
|
|
|
$ lines <$> browse "Data.Either"
|
2013-09-03 11:44:59 +09:00
|
|
|
syms `shouldContain` ["either :: (a -> c) -> (b -> c) -> Either a b -> c"]
|
2013-03-01 22:11:02 +09:00
|
|
|
|
2014-07-11 03:10:37 +02:00
|
|
|
it "contains type constructors (e.g. `Left') including their type signature" $ do
|
2015-09-01 10:27:12 +02:00
|
|
|
syms <- run defaultOptions { optDetailed = True}
|
2014-05-10 15:10:34 +02:00
|
|
|
$ lines <$> browse "Data.Either"
|
2013-09-03 11:44:59 +09:00
|
|
|
syms `shouldContain` ["Left :: a -> Either a b"]
|
2013-11-20 08:57:45 +04:00
|
|
|
|
2014-07-11 03:10:37 +02:00
|
|
|
describe "`browse' in a project directory" $ do
|
2015-03-04 21:48:21 +01:00
|
|
|
it "can list symbols defined in a a local module" $ do
|
|
|
|
|
withDirectory_ "test/data/ghc-mod-check/lib" $ do
|
|
|
|
|
syms <- runD $ lines <$> browse "Data.Foo"
|
|
|
|
|
syms `shouldContain` ["foo"]
|
|
|
|
|
syms `shouldContain` ["fibonacci"]
|