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

fix empty heap test

This commit is contained in:
joshvera 2018-11-15 18:44:47 -05:00
parent 46d39a25c8
commit 2f32fd6f2b
2 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,7 @@ module Data.Abstract.Heap
, pathDeclaration
, lookupFrameAddress
, lookupDeclaration
, isHeapEmpty
) where
import Data.Abstract.Live
@ -104,6 +105,13 @@ fillFrame address slots heap =
heapSize :: Heap scope address value -> Int
heapSize = Map.size . heap
isHeapEmpty :: (Eq address, Eq value) => Heap scope address value -> Bool
isHeapEmpty h@Heap{..} = isJust currentFrame &&
(heapSize h) == 1 &&
(toEmptyFrame <$> Map.elems heap) == [ Frame () mempty mempty ]
where
toEmptyFrame Frame{..} = Frame () (Map.mapKeysMonotonic (const ()) <$> links) slots
-- -- | A map of addresses onto cells holding their values.
-- newtype Heap address address value = Heap { unHeap :: Monoidal.Map address (Set value) }
-- deriving (Eq, Foldable, Lower, Monoid, Ord, Semigroup)

View File

@ -73,7 +73,7 @@ spec config = parallel $ do
it "side effect only imports" $ do
(_, res) <- evaluate ["main2.ts", "a.ts", "foo.ts"]
case ModuleTable.lookup "main2.ts" <$> res of
Right (Just (Module _ (_, (heap, _)) :| [])) -> heap `shouldBe` lowerBound
Right (Just (Module _ (_, (heap, _)) :| [])) -> heap `shouldSatisfy` Heap.isHeapEmpty
other -> expectationFailure (show other)
it "fails exporting symbols not defined in the module" $ do