mirror of
https://github.com/github/semantic.git
synced 2024-12-18 04:11:48 +03:00
Fix up test for ModuleInfo changes
This commit is contained in:
parent
13fe8e14bc
commit
70ea830460
@ -35,7 +35,7 @@ spec session = parallel $ do
|
|||||||
|
|
||||||
it "evaluates load with wrapper" $ do
|
it "evaluates load with wrapper" $ do
|
||||||
(_, (_, res)) <- evaluate ["load-wrap.rb", "foo.rb"]
|
(_, (_, res)) <- evaluate ["load-wrap.rb", "foo.rb"]
|
||||||
res `shouldBe` Left (SomeError (inject @(BaseError (ScopeError Precise)) (BaseError (ModuleInfo "load-wrap.rb") (Span (Pos 3 1) (Pos 3 7)) (LookupPathError (Declaration "foo")))))
|
res `shouldBe` Left (SomeError (inject @(BaseError (ScopeError Precise)) (BaseError (ModuleInfo "load-wrap.rb" Language.Ruby mempty) (Span (Pos 3 1) (Pos 3 7)) (LookupPathError (Declaration "foo")))))
|
||||||
|
|
||||||
it "evaluates subclass" $ do
|
it "evaluates subclass" $ do
|
||||||
(scopeGraph, (heap, res)) <- evaluate ["subclass.rb"]
|
(scopeGraph, (heap, res)) <- evaluate ["subclass.rb"]
|
||||||
|
@ -84,7 +84,7 @@ spec session = parallel $ do
|
|||||||
|
|
||||||
it "fails exporting symbols not defined in the module" $ do
|
it "fails exporting symbols not defined in the module" $ do
|
||||||
(_, (_, res)) <- evaluate ["bad-export.ts", "pip.ts", "a.ts", "foo.ts"]
|
(_, (_, res)) <- evaluate ["bad-export.ts", "pip.ts", "a.ts", "foo.ts"]
|
||||||
res `shouldBe` Left (SomeError (inject @(BaseError (ScopeError Precise)) (BaseError (ModuleInfo "bad-export.ts") (Span (Pos 2 1) (Pos 2 28)) ImportReferenceError)))
|
res `shouldBe` Left (SomeError (inject @(BaseError (ScopeError Precise)) (BaseError (ModuleInfo "bad-export.ts" Language.TypeScript mempty) (Span (Pos 2 1) (Pos 2 28)) ImportReferenceError)))
|
||||||
|
|
||||||
it "evaluates early return statements" $ do
|
it "evaluates early return statements" $ do
|
||||||
(scopeGraph, (heap, res)) <- evaluate ["early-return.ts"]
|
(scopeGraph, (heap, res)) <- evaluate ["early-return.ts"]
|
||||||
@ -168,17 +168,17 @@ spec session = parallel $ do
|
|||||||
|
|
||||||
it "member access of private field definition throws AccessControlError" $ do
|
it "member access of private field definition throws AccessControlError" $ do
|
||||||
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_field_definition.ts"]
|
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_field_definition.ts"]
|
||||||
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_field_definition.ts") (Span (Pos 4 1) (Pos 4 6)) (AccessControlError ("foo", ScopeGraph.Public) ("y", ScopeGraph.Private) (Concrete.Float (Decimal 2.0))))))
|
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_field_definition.ts" Language.TypeScript mempty) (Span (Pos 4 1) (Pos 4 6)) (AccessControlError ("foo", ScopeGraph.Public) ("y", ScopeGraph.Private) (Concrete.Float (Decimal 2.0))))))
|
||||||
res `shouldBe` expected
|
res `shouldBe` expected
|
||||||
|
|
||||||
it "member access of private static field definition throws AccessControlError" $ do
|
it "member access of private static field definition throws AccessControlError" $ do
|
||||||
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_static_field_definition.ts"]
|
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_static_field_definition.ts"]
|
||||||
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_static_field_definition.ts") (Span (Pos 3 1) (Pos 3 8)) (AccessControlError ("Adder", ScopeGraph.Public) ("z", ScopeGraph.Private) Unit))))
|
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_static_field_definition.ts" Language.TypeScript mempty) (Span (Pos 3 1) (Pos 3 8)) (AccessControlError ("Adder", ScopeGraph.Public) ("z", ScopeGraph.Private) Unit))))
|
||||||
res `shouldBe` expected
|
res `shouldBe` expected
|
||||||
|
|
||||||
it "member access of private methods throws AccessControlError" $ do
|
it "member access of private methods throws AccessControlError" $ do
|
||||||
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_method.ts"]
|
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_method.ts"]
|
||||||
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_method.ts") (Span (Pos 4 1) (Pos 4 16)) (AccessControlError ("foo", ScopeGraph.Public) ("private_add", ScopeGraph.Private) (Closure (PackageInfo "access_control" mempty) (ModuleInfo "adder.ts") (Just "private_add") Nothing [] (Right (Quieterm (In (Location (Range 146 148) (Span (Pos 7 27) (Pos 7 29))) (inject (StatementBlock []))))) (Precise 20) (Precise 18))))))
|
let expected = Left (SomeError (inject @TypeScriptEvalError (BaseError (ModuleInfo "private_method.ts" Language.TypeScript mempty) (Span (Pos 4 1) (Pos 4 16)) (AccessControlError ("foo", ScopeGraph.Public) ("private_add", ScopeGraph.Private) (Closure (PackageInfo "access_control" mempty) (ModuleInfo "adder.ts" Language.TypeScript mempty) (Just "private_add") Nothing [] (Right (Quieterm (In (Location (Range 146 148) (Span (Pos 7 27) (Pos 7 29))) (inject (StatementBlock []))))) (Precise 20) (Precise 18))))))
|
||||||
res `shouldBe` expected
|
res `shouldBe` expected
|
||||||
|
|
||||||
where
|
where
|
||||||
|
@ -17,6 +17,7 @@ import Data.Abstract.Value.Concrete as Value
|
|||||||
import Data.Algebra
|
import Data.Algebra
|
||||||
import Data.Bifunctor (first)
|
import Data.Bifunctor (first)
|
||||||
import Data.Functor.Const
|
import Data.Functor.Const
|
||||||
|
import qualified Data.Language as Language
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Data.Sum
|
import Data.Sum
|
||||||
import Data.Text (pack)
|
import Data.Text (pack)
|
||||||
@ -51,7 +52,7 @@ evaluate
|
|||||||
. runState (lowerBound @(Heap Precise Precise Val))
|
. runState (lowerBound @(Heap Precise Precise Val))
|
||||||
. runFresh
|
. runFresh
|
||||||
. runReader (PackageInfo (SpecHelpers.name "test") mempty)
|
. runReader (PackageInfo (SpecHelpers.name "test") mempty)
|
||||||
. runReader (ModuleInfo "test/Control/Abstract/Evaluator/Spec.hs")
|
. runReader (ModuleInfo "test/Control/Abstract/Evaluator/Spec.hs" Language.Haskell mempty)
|
||||||
. evalState (lowerBound @Span)
|
. evalState (lowerBound @Span)
|
||||||
. runReader (lowerBound @Span)
|
. runReader (lowerBound @Span)
|
||||||
. runEvaluator
|
. runEvaluator
|
||||||
|
Loading…
Reference in New Issue
Block a user