Browse files

bugfix: default "nubBy" differed from standard nubBy

Clean up testing code
Remove tests of nested data structures, they take far too long to use
  • Loading branch information...
1 parent 118c1ef commit f16fc70909afcb872eabc96fd42e207cd4fcb611 @JohnLato JohnLato committed Feb 4, 2011
Showing with 10 additions and 7 deletions.
  1. +9 −0 src/Data/ListLike/Base.hs
  2. +0 −5 testsrc/TestInfrastructure.hs
  3. +1 −2 testsrc/runtests.hs
View
9 src/Data/ListLike/Base.hs
@@ -423,10 +423,19 @@ class (FoldableLL full item, Monoid full) =>
------------------------------ Generalized functions
{- | Generic version of 'nub' -}
nubBy :: (item -> item -> Bool) -> full -> full
+ nubBy f l = nubBy' l (empty :: full)
+ where
+ nubBy' ys xs
+ | null ys = empty
+ | any (f (head ys)) xs = nubBy' (tail ys) xs
+ | otherwise = let y = head ys
+ in cons y (nubBy' (tail ys) (cons y xs))
+{-
nubBy f l
| null l = empty
| otherwise =
cons (head l) (nubBy f (filter (\y -> not (f (head l) y)) (tail l)))
+-}
{- | Generic version of 'deleteBy' -}
deleteBy :: (item -> item -> Bool) -> item -> full -> full
View
5 testsrc/TestInfrastructure.hs
@@ -183,11 +183,6 @@ apf msg x = HU.TestLabel msg $ HU.TestList $
w "ByteString.Lazy" (x::LLTest BSL.ByteString Word8),
w "Array Int Int" (x::LLTest (A.Array Int Int) Int),
w "Array Int Bool" (x::LLTest (A.Array Int Bool) Bool),
- w "[[Int]]" (x::LLTest [[Int]] [Int]),
- w "MyList (MyList Int)" (x::LLTest (MyList (MyList Int)) (MyList Int)),
- w "[MyList Int]" (x::LLTest [MyList Int] (MyList Int)),
- w "Array [Int]" (x::LLTest (A.Array Int [Int]) [Int]),
- w "Array (Array Int)" (x::LLTest (A.Array Int (A.Array Int Int)) (A.Array Int Int)),
w "Array (Just Int)" (x::LLTest (A.Array Int (Maybe Int)) (Maybe Int))
]
View
3 testsrc/runtests.hs
@@ -84,8 +84,7 @@ prop_any f func = (LL.any func f) == (any func (LL.toList f))
prop_all f func = (LL.all func f) == (all func (LL.toList f))
prop_maximum f = not (LL.null f) ==> LL.maximum f == maximum (LL.toList f)
prop_minimum f = not (LL.null f) ==> LL.minimum f == minimum (LL.toList f)
-prop_replicate f count i =
- llcmp res (replicate count i)
+prop_replicate f count i = count <= 1000 ==> llcmp res (replicate count i)
where res = asTypeOf (LL.replicate count i) f
prop_take f count = llcmp (LL.take count f) (take count (LL.toList f))
prop_drop f count = count >= 0 ==> llcmp (LL.drop count f) (drop count (LL.toList f))

0 comments on commit f16fc70

Please sign in to comment.