1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Test that tableOfContentsBy includes all nodes with constant Just functions.

This commit is contained in:
Rob Rix 2017-05-11 09:27:28 -04:00
parent 0bb408bf06
commit 1dc74959b8

View File

@ -31,6 +31,12 @@ spec = parallel $ do
describe "tableOfContentsBy" $ do
prop "drops all nodes with the constant Nothing function" $
\ diff -> tableOfContentsBy (const Nothing :: a -> Maybe ()) (unListableDiff diff :: Diff (Syntax ()) ()) `shouldBe` []
let entryValue e = case e of { Unchanged a -> a; Changed a -> a ; Patched p -> afterOrBefore p }
let diffSize = cata (succ . sum) . fmap (termSize . afterOrBefore)
prop "includes all nodes with a constant Just function" $
\ diff -> let diff' = (unListableDiff diff :: Diff (Syntax ()) ()) in entryValue <$> tableOfContentsBy (const (Just ())) diff' `shouldBe` replicate (diffSize diff') ()
describe "diffTOC" $ do
it "blank if there are no methods" $
diffTOC blankDiffBlobs blankDiff `shouldBe` [ ]