From 9c008f11166cbfa595812edeb85b98b722031c94 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 26 Apr 2016 15:44:11 -0400 Subject: [PATCH] Add a (failing) test that numberedRows produces the correct counts. --- test/AlignmentSpec.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/AlignmentSpec.hs b/test/AlignmentSpec.hs index 06bd7e00b..2b3f6b1ee 100644 --- a/test/AlignmentSpec.hs +++ b/test/AlignmentSpec.hs @@ -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))