diff --git a/src/Control/Abstract/Modules.hs b/src/Control/Abstract/Modules.hs index 46970f12d..d9dc10c5a 100644 --- a/src/Control/Abstract/Modules.hs +++ b/src/Control/Abstract/Modules.hs @@ -26,7 +26,6 @@ import Data.Abstract.BaseError import Data.Abstract.Module import Data.Abstract.ModuleTable as ModuleTable import Data.Language -import Data.Semigroup.Foldable (foldMap1) import qualified Data.Set as Set import Data.Span import Prologue @@ -83,7 +82,7 @@ sendModules :: ( Member (Modules address value) sig -> Evaluator term address value m return sendModules = send -runModules :: ( Member (Reader (ModuleTable (NonEmpty (Module (ModuleResult address value))))) sig +runModules :: ( Member (Reader (ModuleTable (Module (ModuleResult address value)))) sig , Member (Resumable (BaseError (LoadError address value))) sig , Carrier sig m ) @@ -94,7 +93,7 @@ runModules paths = raiseHandler $ flip runModulesC paths . interpret newtype ModulesC address value m a = ModulesC { runModulesC :: Set ModulePath -> m a } -instance ( Member (Reader (ModuleTable (NonEmpty (Module (ModuleResult address value))))) sig +instance ( Member (Reader (ModuleTable (Module (ModuleResult address value)))) sig , Member (Resumable (BaseError (LoadError address value))) sig , Carrier sig m , Monad m @@ -102,22 +101,15 @@ instance ( Member (Reader (ModuleTable (NonEmpty (Module (ModuleResult address v => Carrier (Modules address value :+: sig) (ModulesC address value m) where ret = ModulesC . const . ret eff op = ModulesC (\ paths -> handleSum (eff . handleReader paths runModulesC) (\case - Load name k -> askModuleTable >>= maybeM (throwLoadError (ModuleNotFoundError name)) . fmap (runMerging . foldMap1 (Merging . moduleBody)) . ModuleTable.lookup name >>= flip runModulesC paths . k - Lookup path k -> askModuleTable >>= flip runModulesC paths . k . fmap (runMerging . foldMap1 (Merging . moduleBody)) . ModuleTable.lookup path + Load name k -> askModuleTable >>= maybeM (throwLoadError (ModuleNotFoundError name)) . fmap moduleBody . ModuleTable.lookup name >>= flip runModulesC paths . k + Lookup path k -> askModuleTable >>= flip runModulesC paths . k . fmap moduleBody . ModuleTable.lookup path Resolve names k -> runModulesC (k (find (`Set.member` paths) names)) paths List dir k -> runModulesC (k (filter ((dir ==) . takeDirectory) (toList paths))) paths) op) -askModuleTable :: (Member (Reader (ModuleTable (NonEmpty (Module (ModuleResult address value))))) sig, Carrier sig m) => m (ModuleTable (NonEmpty (Module (ModuleResult address value)))) +askModuleTable :: (Member (Reader (ModuleTable (Module (ModuleResult address value)))) sig, Carrier sig m) => m (ModuleTable (Module (ModuleResult address value))) askModuleTable = ask -newtype Merging address value = Merging { runMerging :: ModuleResult address value } - -instance Semigroup (Merging address value) where - -- TODO: We may need to combine graphs - Merging ((_, _), _) <> Merging ((graph2, heap2), val) = Merging ((graph2, heap2), val) - - -- | An error thrown when loading a module from the list of provided modules. Indicates we weren't able to find a module with the given name. data LoadError address value resume where ModuleNotFoundError :: ModulePath -> LoadError address value (ModuleResult address value) diff --git a/src/Semantic/Analysis.hs b/src/Semantic/Analysis.hs index adc8c4254..6ae4ae2db 100644 --- a/src/Semantic/Analysis.hs +++ b/src/Semantic/Analysis.hs @@ -57,7 +57,7 @@ evaluate :: ( AbstractValue term address value (ValueC term address value inner) , Member (Deref value) innerSig , Member Fresh innerSig , Member (Reader ModuleInfo) innerSig - , Member (Reader (ModuleTable (NonEmpty (Module (ModuleResult address value))))) outerSig + , Member (Reader (ModuleTable (Module (ModuleResult address value)))) outerSig , Member (Reader Span) innerSig , Member (Resumable (BaseError (AddressError address value))) innerSig , Member (Resumable (BaseError (UnspecializedError address value))) innerSig @@ -78,15 +78,14 @@ evaluate :: ( AbstractValue term address value (ValueC term address value inner) -> (Module (Either (proxy lang) term) -> Evaluator term address value (ModuleC address value outer) value)) -> (term -> Evaluator term address value (ValueC term address value inner) value) -> [Module term] - -> Evaluator term address value outer (ModuleTable (NonEmpty (Module (ModuleResult address value)))) + -> Evaluator term address value outer (ModuleTable (Module (ModuleResult address value))) evaluate lang perModule runTerm modules = do let prelude = Module moduleInfoFromCallStack (Left lang) ((preludeScopeAddress, preludeFrameAddress), _) <- evalModule Nothing Nothing prelude foldr (run preludeScopeAddress preludeFrameAddress . fmap Right) ask modules where run preludeScopeAddress preludeFrameAddress m rest = do evaluated <- evalModule (Just preludeScopeAddress) (Just preludeFrameAddress) m - -- FIXME: this should be some sort of Monoidal insert à la the Heap to accommodate multiple Go files being part of the same module. - local (ModuleTable.insert (modulePath (moduleInfo m)) ((evaluated <$ m) :| [])) rest + local (ModuleTable.insert (modulePath (moduleInfo m)) (evaluated <$ m)) rest -- Run the allocator and Reader ModuleInfo effects (Some allocator instances depend on Reader ModuleInfo) -- after setting up the scope and frame for a module. diff --git a/src/Semantic/Graph.hs b/src/Semantic/Graph.hs index c8d79c201..ef42f3e11 100644 --- a/src/Semantic/Graph.hs +++ b/src/Semantic/Graph.hs @@ -139,7 +139,7 @@ runCallGraph lang includePackages modules package runModuleTable :: Carrier sig m - => Evaluator term address value (ReaderC (ModuleTable (NonEmpty (Module (ModuleResult address value)))) (Eff m)) a + => Evaluator term address value (ReaderC (ModuleTable (Module (ModuleResult address value))) (Eff m)) a -> Evaluator term address value m a runModuleTable = raiseHandler $ runReader lowerBound diff --git a/test/Analysis/Go/Spec.hs b/test/Analysis/Go/Spec.hs index 2802e4b89..7c3b8fe80 100644 --- a/test/Analysis/Go/Spec.hs +++ b/test/Analysis/Go/Spec.hs @@ -13,7 +13,7 @@ spec config = parallel $ do it "imports and wildcard imports" $ do (scopeGraph, (heap, res)) <- evaluate ["main.go", "foo/foo.go", "bar/bar.go", "bar/rab.go"] case ModuleTable.lookup "main.go" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do () <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () SpecHelpers.lookupMembers "foo" Import scopeAndFrame heap scopeGraph `shouldBe` Just ["New"] () <$ SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -24,7 +24,7 @@ spec config = parallel $ do it "imports with aliases (and side effects only)" $ do (scopeGraph, (heap, res)) <- evaluate ["main1.go", "foo/foo.go", "bar/bar.go", "bar/rab.go"] case ModuleTable.lookup "main1.go" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do const () <$> SpecHelpers.lookupDeclaration "f" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldBe` Just () -- (lookupDeclaration "f" heap >>= deNamespace heap) `shouldBe` Just ("f", ["New"]) diff --git a/test/Analysis/PHP/Spec.hs b/test/Analysis/PHP/Spec.hs index 6afd4b3ee..3bc7b498b 100644 --- a/test/Analysis/PHP/Spec.hs +++ b/test/Analysis/PHP/Spec.hs @@ -14,7 +14,7 @@ spec config = parallel $ do xit "evaluates include and require" $ do (scopeGraph, (heap, res)) <- evaluate ["main.php", "foo.php", "bar.php"] case ModuleTable.lookup "main.php" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` unit const () <$> SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -23,7 +23,7 @@ spec config = parallel $ do xit "evaluates include_once and require_once" $ do (scopeGraph, (heap, res)) <- evaluate ["main_once.php", "foo.php", "bar.php"] case ModuleTable.lookup "main_once.php" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` unit const () <$> SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -32,7 +32,7 @@ spec config = parallel $ do xit "evaluates namespaces" $ do (scopeGraph, (heap, res)) <- evaluate ["namespaces.php"] case ModuleTable.lookup "namespaces.php" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "NS1" scopeAndFrame heap scopeGraph `shouldBe` Just () diff --git a/test/Analysis/Python/Spec.hs b/test/Analysis/Python/Spec.hs index 88d947b2c..af47b0482 100644 --- a/test/Analysis/Python/Spec.hs +++ b/test/Analysis/Python/Spec.hs @@ -15,7 +15,7 @@ spec config = parallel $ do it "imports" $ do (scopeGraph, (heap, res)) <- evaluate ["main.py", "a.py", "b/__init__.py", "b/c.py"] case ModuleTable.lookup "main.py" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do const () <$> SpecHelpers.lookupDeclaration "a" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -27,7 +27,7 @@ spec config = parallel $ do it "imports with aliases" $ do (scopeGraph, (heap, res)) <- evaluate ["main1.py", "a.py", "b/__init__.py", "b/c.py"] case ModuleTable.lookup "main1.py" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "e" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) @@ -35,7 +35,7 @@ spec config = parallel $ do it "imports using from syntax" $ do (scopeGraph, (heap, res)) <- evaluate ["main2.py", "a.py", "b/__init__.py", "b/c.py"] case ModuleTable.lookup "main2.py" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -46,7 +46,7 @@ spec config = parallel $ do it "imports with relative syntax" $ do (scopeGraph, (heap, res)) <- evaluate ["main3.py", "c/__init__.py", "c/utils.py"] case ModuleTable.lookup "main3.py" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "utils" scopeAndFrame heap scopeGraph `shouldBe` Just () -- (lookupDeclaration "utils" heap >>= deNamespace heap) `shouldBe` Just ("utils", ["to_s"]) other -> expectationFailure (show other) @@ -54,7 +54,7 @@ spec config = parallel $ do it "subclasses" $ do (scopeGraph, (heap, res)) <- evaluate ["subclass.py"] case ModuleTable.lookup "subclass.py" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do () <$ SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just () () <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just () SpecHelpers.lookupMembers "Bar" Superclass scopeAndFrame heap scopeGraph `shouldBe` Just [ "dang" ] @@ -64,7 +64,7 @@ spec config = parallel $ do it "handles multiple inheritance left-to-right" $ do (scopeGraph, (heap, res)) <- evaluate ["multiple_inheritance.py"] case ModuleTable.lookup "multiple_inheritance.py" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do SpecHelpers.lookupMembers "Baz" Superclass scopeAndFrame heap scopeGraph `shouldBe` Just [ "dang" ] value `shouldBe` String "\"bar!\"" other -> expectationFailure (show other) diff --git a/test/Analysis/Ruby/Spec.hs b/test/Analysis/Ruby/Spec.hs index 22fe9e04e..f742db17e 100644 --- a/test/Analysis/Ruby/Spec.hs +++ b/test/Analysis/Ruby/Spec.hs @@ -20,7 +20,7 @@ spec config = parallel $ do it "evaluates require_relative" $ do (scopeGraph, (heap, res)) <- evaluate ["main.rb", "foo.rb"] case ModuleTable.lookup "main.rb" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` Value.Integer (Number.Integer 1) () <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) @@ -28,7 +28,7 @@ spec config = parallel $ do it "evaluates load" $ do (scopeGraph, (heap, res)) <- evaluate ["load.rb", "foo.rb"] case ModuleTable.lookup "load.rb" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` Value.Integer (Number.Integer 1) () <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) @@ -40,7 +40,7 @@ spec config = parallel $ do it "evaluates subclass" $ do (scopeGraph, (heap, res)) <- evaluate ["subclass.rb"] case ModuleTable.lookup "subclass.rb" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` String "\"\"" () <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just () () <$ SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -50,50 +50,50 @@ spec config = parallel $ do it "evaluates modules" $ do (scopeGraph, (heap, res)) <- evaluate ["modules.rb"] case ModuleTable.lookup "modules.rb" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) it "handles break correctly" $ do (_, (_, res)) <- evaluate ["break.rb"] case ModuleTable.lookup "break.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 3) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 3) other -> expectationFailure (show other) it "handles next correctly" $ do (_, (_, res)) <- evaluate ["next.rb"] case ModuleTable.lookup "next.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 8) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 8) other -> expectationFailure (show other) it "calls functions with arguments" $ do (_, (_, res)) <- evaluate ["call.rb"] case ModuleTable.lookup "call.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 579) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 579) other -> expectationFailure (show other) it "evaluates early return statements" $ do (_, (_, res)) <- evaluate ["early-return.rb"] case ModuleTable.lookup "early-return.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 123) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 123) other -> expectationFailure (show other) it "has prelude" $ do (_, (_, res)) <- evaluate ["preluded.rb"] case ModuleTable.lookup "preluded.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` String "\"\"" + Right (Just (Module _ (_, value))) -> value `shouldBe` String "\"\"" other -> expectationFailure (show other) it "evaluates __LINE__" $ do (_, (_, res)) <- evaluate ["line.rb"] case ModuleTable.lookup "line.rb" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 4) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 4) other -> expectationFailure (show other) it "resolves builtins used in the prelude" $ do (scopeGraph, (heap, res)) <- evaluate ["puts.rb"] case ModuleTable.lookup "puts.rb" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` Unit const () <$> SpecHelpers.lookupDeclaration "puts" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) diff --git a/test/Analysis/TypeScript/Spec.hs b/test/Analysis/TypeScript/Spec.hs index 6343e202b..37ee75308 100644 --- a/test/Analysis/TypeScript/Spec.hs +++ b/test/Analysis/TypeScript/Spec.hs @@ -27,14 +27,14 @@ spec config = parallel $ do it "qualified export from" $ do (scopeGraph, (heap, res)) <- evaluate ["main6.ts", "baz.ts", "foo.ts"] case ModuleTable.lookup "main6.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do () <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) it "imports with aliased symbols" $ do (scopeGraph, (heap, res)) <- evaluate ["main.ts", "foo.ts", "a.ts", "foo/b.ts"] case ModuleTable.lookup "main.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do const () <$> SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just () const () <$> SpecHelpers.lookupDeclaration "quz" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -43,7 +43,7 @@ spec config = parallel $ do it "imports with qualified names" $ do (scopeGraph, (heap, res)) <- evaluate ["main1.ts", "foo.ts", "a.ts"] case ModuleTable.lookup "main1.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, _))) -> do () <$ SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just () () <$ SpecHelpers.lookupDeclaration "z" scopeAndFrame heap scopeGraph `shouldBe` Just () @@ -57,7 +57,7 @@ spec config = parallel $ do it "stores function declaration in scope graph" $ do (scopeGraph, (heap, res)) <- evaluate ["a.ts"] case ModuleTable.lookup "a.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Just () value `shouldBe` Unit other -> expectationFailure (show other) @@ -65,7 +65,7 @@ spec config = parallel $ do it "imports functions" $ do (scopeGraph, (heap, res)) <- evaluate ["main4.ts", "foo.ts"] case ModuleTable.lookup "main4.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do const () <$> SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () value `shouldBe` String (pack "\"this is the foo function\"") other -> expectationFailure (show other) @@ -73,7 +73,7 @@ spec config = parallel $ do it "side effect only imports dont expose exports" $ do (scopeGraph, (heap, res)) <- evaluate ["main3.ts", "a.ts"] case ModuleTable.lookup "main3.ts" <$> res of - Right (Just (Module _ (scopeAndFrame@(currentScope, currentFrame), value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame@(currentScope, currentFrame), value))) -> do () <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing value `shouldBe` Unit Heap.heapSize heap `shouldBe` 4 @@ -86,27 +86,27 @@ spec config = parallel $ do it "evaluates early return statements" $ do (scopeGraph, (heap, res)) <- evaluate ["early-return.ts"] case ModuleTable.lookup "early-return.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> + Right (Just (Module _ (scopeAndFrame, value))) -> const () <$> SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just () other -> expectationFailure (show other) it "evaluates sequence expressions" $ do (scopeGraph, (heap, res)) <- evaluate ["sequence-expression.ts"] case ModuleTable.lookup "sequence-expression.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> + Right (Just (Module _ (scopeAndFrame, value))) -> SpecHelpers.lookupDeclaration "x" scopeAndFrame heap scopeGraph `shouldBe` Just [ Value.float (scientific 3 0) ] other -> expectationFailure (show other) it "evaluates void expressions" $ do (_, (_, res)) <- evaluate ["void.ts"] case ModuleTable.lookup "void.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Null + Right (Just (Module _ (_, value))) -> value `shouldBe` Null other -> expectationFailure (show other) it "evaluates delete" $ do (scopeGraph, (heap, res)) <- evaluate ["delete.ts"] case ModuleTable.lookup "delete.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do value `shouldBe` Unit SpecHelpers.lookupDeclaration "x" scopeAndFrame heap scopeGraph `shouldBe` Nothing other -> expectationFailure (show other) @@ -114,7 +114,7 @@ spec config = parallel $ do it "evaluates await" $ do (scopeGraph, (heap, res)) <- evaluate ["await.ts"] case ModuleTable.lookup "await.ts" <$> res of - Right (Just (Module _ (scopeAndFrame, value) :| [])) -> do + Right (Just (Module _ (scopeAndFrame, value))) -> do -- Test that f2 is in the scopegraph and heap. const () <$> SpecHelpers.lookupDeclaration "f2" scopeAndFrame heap scopeGraph `shouldBe` Just () -- Test we can't reference y from outside the function @@ -124,38 +124,38 @@ spec config = parallel $ do it "evaluates BOr statements" $ do (_, (_, res)) <- evaluate ["bor.ts"] case ModuleTable.lookup "bor.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 3) other -> expectationFailure (show other) it "evaluates BAnd statements" $ do (_, (_, res)) <- evaluate ["band.ts"] case ModuleTable.lookup "band.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 0) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 0) other -> expectationFailure (show other) it "evaluates BXOr statements" $ do (_, (_, res)) <- evaluate ["bxor.ts"] case ModuleTable.lookup "bxor.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 3) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 3) other -> expectationFailure (show other) it "evaluates LShift statements" $ do (_, (_, res)) <- evaluate ["lshift.ts"] case ModuleTable.lookup "lshift.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 4) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 4) other -> expectationFailure (show other) it "evaluates RShift statements" $ do (_, (_, res)) <- evaluate ["rshift.ts"] case ModuleTable.lookup "rshift.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer 0) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer 0) other -> expectationFailure (show other) it "evaluates Complement statements" $ do (_, (_, res)) <- evaluate ["complement.ts"] case ModuleTable.lookup "complement.ts" <$> res of - Right (Just (Module _ (_, value) :| [])) -> value `shouldBe` Value.Integer (Number.Integer (-2)) + Right (Just (Module _ (_, value))) -> value `shouldBe` Value.Integer (Number.Integer (-2)) other -> expectationFailure (show other)