mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Add a (failing) test that numberedRows produces the correct counts.
This commit is contained in:
parent
64dd8d93da
commit
9c008f1116
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user