1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Add a (failing) test that numberedRows produces the correct counts.

This commit is contained in:
Rob Rix 2016-04-26 15:44:11 -04:00
parent 64dd8d93da
commit 9c008f1116

View File

@ -1,6 +1,7 @@
module AlignmentSpec where
import Alignment
import ArbitraryTerm ()
import Control.Comonad.Cofree
import Control.Monad.Free
import Data.Align
@ -22,6 +23,7 @@ import qualified Source
import SplitDiff
import Syntax
import Test.Hspec
import Test.Hspec.QuickCheck
spec :: Spec
spec = parallel $ do
@ -100,6 +102,10 @@ spec = parallel $ do
(info 4 5 `branch` [ info 4 5 `leaf` "c" ]))
]
describe "numberedRows" $
prop "counts only non-empty values" $
\ xs -> counts (numberedRows (xs :: [Join These Char])) `shouldBe` length . catMaybes <$> Join (unalign (runJoin <$> xs))
counts :: [Join These (Int, a)] -> Both Int
counts numbered = fromMaybe 0 . getLast . mconcat . fmap Last <$> Join (unalign (runJoin . fmap Prelude.fst <$> numbered))