1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Add imports functions test

Co-Authored-By: Rick Winfrey <rick.winfrey@gmail.com>
This commit is contained in:
joshvera 2018-11-13 14:09:13 -05:00
parent 56b85b1070
commit ddb9b31a09

View File

@ -14,6 +14,7 @@ import Data.Sum
import SpecHelpers
import qualified Data.Abstract.ScopeGraph as ScopeGraph
import qualified Data.Abstract.Heap as Heap
import Data.Text (pack)
spec :: TaskConfig -> Spec
spec config = parallel $ do
@ -40,7 +41,7 @@ spec config = parallel $ do
(fmap (const ()) <$> ScopeGraph.lookupScopePath "foo" scopeGraph) `shouldBe` Just (ScopeGraph.EPath ScopeGraph.Import () (ScopeGraph.DPath (ScopeGraph.Declaration "foo") (Heap.Position 1) ))
other -> expectationFailure (show other)
it "imports functions" $ do
it "stores function declaration in scope graph" $ do
(_, res) <- evaluate ["a.ts"]
case ModuleTable.lookup "a.ts" <$> res of
Right (Just (Module _ (scopeGraph, (heap, valueRef)) :| [])) -> do
@ -50,6 +51,14 @@ spec config = parallel $ do
closure' valueRef `shouldBe` Right (Closure (PackageInfo { packageName = "analysis", packageResolutions = mempty }) (ModuleInfo "a.ts") "baz" [] (Right ()) ())
other -> expectationFailure (show other)
it "imports functions" $ do
(_, res) <- evaluate ["main4.ts", "foo.ts"]
case ModuleTable.lookup "main4.ts" <$> res of
Right (Just (Module _ (scopeGraph, (heap, valueRef)) :| [])) -> do
fmap (const ()) <$> ScopeGraph.lookupScopePath "foo" scopeGraph `shouldBe` Just (ScopeGraph.EPath ScopeGraph.Import () $ ScopeGraph.DPath (ScopeGraph.Declaration "foo") (Heap.Position 0))
valueRef `shouldBe` Rval (String $ pack "this is the foo function")
other -> expectationFailure (show other)
it "side effect only imports dont expose exports" $ do
(_, res) <- evaluate ["main3.ts", "a.ts"]
case ModuleTable.lookup "main3.ts" <$> res of