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