packages feed

numeric-prelude-0.1: test/Test/NumericPrelude/Utility.hs

-- cf. utility-ht Test.Utility
module Test.NumericPrelude.Utility where

import Data.List.HT (mapAdjacent, )
import qualified Data.List as List
import qualified Test.HUnit as HUnit


testUnit :: (String, IO ()) -> HUnit.Test
testUnit (label, check) =
   HUnit.TestLabel label (HUnit.TestCase check)

-- compare the lists simultaneously
equalLists :: Eq a => [[a]] -> Bool
equalLists xs =
   let equalElems ys =
          and (mapAdjacent (==) ys)  &&  length xs == length ys
   in  all equalElems (List.transpose xs)

equalInfLists :: Eq a => Int -> [[a]] -> Bool
equalInfLists n xs = equalLists (map (take n) xs)