mirror of
https://github.com/github/semantic.git
synced 2025-01-01 11:46:14 +03:00
Fixup a few more tests
This commit is contained in:
parent
ca0508c471
commit
1cfd61ca0a
@ -11,6 +11,7 @@ import qualified Data.List.NonEmpty as NonEmpty
|
|||||||
import Data.Sum
|
import Data.Sum
|
||||||
import SpecHelpers
|
import SpecHelpers
|
||||||
import qualified Data.Abstract.ScopeGraph as ScopeGraph
|
import qualified Data.Abstract.ScopeGraph as ScopeGraph
|
||||||
|
import qualified Data.Abstract.Heap as Heap
|
||||||
|
|
||||||
spec :: TaskConfig -> Spec
|
spec :: TaskConfig -> Spec
|
||||||
spec config = parallel $ do
|
spec config = parallel $ do
|
||||||
@ -26,12 +27,15 @@ spec config = parallel $ do
|
|||||||
it "imports with qualified names" $ do
|
it "imports with qualified names" $ do
|
||||||
(_, res) <- evaluate ["main1.ts", "foo.ts", "a.ts"]
|
(_, res) <- evaluate ["main1.ts", "foo.ts", "a.ts"]
|
||||||
case ModuleTable.lookup "main1.ts" <$> res of
|
case ModuleTable.lookup "main1.ts" <$> res of
|
||||||
Right (Just (Module _ (_, (env, _)) :| [])) -> do
|
Right (Just (Module _ (scopeGraph, _) :| [])) -> do
|
||||||
Env.names env `shouldBe` [ "b", "z" ]
|
-- Env.names env `shouldBe` [ "b", "z" ]
|
||||||
|
(fmap (const ()) <$> ScopeGraph.lookupScopePath "b" scopeGraph) `shouldBe` Just (ScopeGraph.DPath (ScopeGraph.Declaration "b") (Position 1))
|
||||||
|
(fmap (const ()) <$> ScopeGraph.lookupScopePath "quz" scopeGraph) `shouldBe` Just (ScopeGraph.DPath (ScopeGraph.Declaration "z") (Position 2))
|
||||||
|
|
||||||
undefined
|
|
||||||
-- (lookupDeclaration "b" heap >>= deNamespace heap) `shouldBe` Just ("b", [ "baz", "foo" ])
|
-- (lookupDeclaration "b" heap >>= deNamespace heap) `shouldBe` Just ("b", [ "baz", "foo" ])
|
||||||
-- (lookupDeclaration "z" heap >>= deNamespace heap) `shouldBe` Just ("z", [ "baz", "foo" ])
|
-- (lookupDeclaration "z" heap >>= deNamespace heap) `shouldBe` Just ("z", [ "baz", "foo" ])
|
||||||
|
(fmap (const ()) <$> ScopeGraph.lookupScopePath "baz" scopeGraph) `shouldBe` Just (ScopeGraph.EPath ScopeGraph.Import () (ScopeGraph.EPath ScopeGraph.Import () (ScopeGraph.DPath (ScopeGraph.Declaration "baz") (Position 1) )))
|
||||||
|
(fmap (const ()) <$> ScopeGraph.lookupScopePath "foo" scopeGraph) `shouldBe` Just (ScopeGraph.EPath ScopeGraph.Import () (ScopeGraph.DPath (ScopeGraph.Declaration "foo") (Position 1) ))
|
||||||
other -> expectationFailure (show other)
|
other -> expectationFailure (show other)
|
||||||
|
|
||||||
it "side effect only imports" $ do
|
it "side effect only imports" $ do
|
||||||
@ -47,15 +51,20 @@ spec config = parallel $ do
|
|||||||
it "evaluates early return statements" $ do
|
it "evaluates early return statements" $ do
|
||||||
(_, res) <- evaluate ["early-return.ts"]
|
(_, res) <- evaluate ["early-return.ts"]
|
||||||
case ModuleTable.lookup "early-return.ts" <$> res of
|
case ModuleTable.lookup "early-return.ts" <$> res of
|
||||||
Right (Just (Module _ (_, (_, addr)) :| [])) -> heapLookupAll addr heap `shouldBe` Just [Value.Float (Number.Decimal 123.0)]
|
Right (Just (Module _ (scopeGraph, _) :| [])) -> (fmap (const ()) <$> ScopeGraph.lookupScopePath "foo" scopeGraph) `shouldBe` Just (ScopeGraph.DPath (ScopeGraph.Declaration "foo") (Position 1))
|
||||||
|
-- heapLookupAll addr heap `shouldBe` Just [Value.Float (Number.Decimal 123.0)]
|
||||||
other -> expectationFailure (show other)
|
other -> expectationFailure (show other)
|
||||||
|
|
||||||
it "evaluates sequence expressions" $ do
|
it "evaluates sequence expressions" $ do
|
||||||
(_, res) <- evaluate ["sequence-expression.ts"]
|
(_, res) <- evaluate ["sequence-expression.ts"]
|
||||||
case ModuleTable.lookup "sequence-expression.ts" <$> res of
|
case ModuleTable.lookup "sequence-expression.ts" <$> res of
|
||||||
Right (Just (Module _ (_, (env, addr)) :| [])) -> do
|
Right (Just (Module _ (scopeGraph, (heap, _)) :| [])) -> do
|
||||||
Env.names env `shouldBe` [ "x" ]
|
-- (lookupDeclaration "x" heap) `shouldBe` Just (Value.Float (Number.Decimal 3.0))
|
||||||
(lookupDeclaration "x" heap) `shouldBe` Just (Value.Float (Number.Decimal 3.0))
|
frameAddress <- Heap.lookupDeclaration "x" scopeGraph heap
|
||||||
|
getSlot frameAddress heap `shouldBe` Just (Value.Float (Number.Decimal 3.0))
|
||||||
|
|
||||||
|
-- Env.names env `shouldBe` [ "x" ]
|
||||||
|
(fmap (const ()) <$> ScopeGraph.lookupScopePath "x" scopeGraph) `shouldBe` Just (ScopeGraph.DPath (ScopeGraph.Declaration "x") (Position 1))
|
||||||
other -> expectationFailure (show other)
|
other -> expectationFailure (show other)
|
||||||
|
|
||||||
it "evaluates void expressions" $ do
|
it "evaluates void expressions" $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user