1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Pull the selection of the last value into a helper.

This commit is contained in:
Rob Rix 2017-05-11 13:07:18 -04:00
parent f7bc08427a
commit d1d5f6454c

View File

@ -35,11 +35,12 @@ spec = parallel $ do
let entryValue e = case e of { Unchanged a -> a; Changed a -> a ; Patched p -> afterOrBefore p }
let diffSize = cata (succ . sum) . fmap (termSize . afterOrBefore)
let lastValue = fromJust . getLast . foldMap (Last . Just)
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') ()
prop "produces an unchanged entry for identity diffs" $
\ term -> let term' = (unListableF term :: Term (Syntax ()) (Record '[Category])) in tableOfContentsBy (Just . headF) (diffTerms term' term') `shouldBe` [Unchanged (fromJust (getLast (foldMap (Last . Just) term')))]
\ term -> let term' = (unListableF term :: Term (Syntax ()) (Record '[Category])) in tableOfContentsBy (Just . headF) (diffTerms term' term') `shouldBe` [Unchanged (lastValue term')]
describe "diffTOC" $ do
it "blank if there are no methods" $