Skip to content

Commit 3648305

Browse files
committed
Fix incomplete patterns in test code
1 parent 10c6079 commit 3648305

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

containers-tests/benchmarks/IntMap.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ maybeDel n | n `mod` 3 == 0 = Nothing
191191
------------------------------------------------------------
192192
interleave :: [Int] -> [Int] -> [Int]
193193
interleave [] ys = ys
194+
interleave xs [] = xs
194195
interleave (x:xs) (y:ys) = x : y : interleave xs ys
195196

196197
unitValues :: [Int] -> [(Int, ())]

containers-tests/benchmarks/IntSet.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fromListNoinline = IS.fromList
139139

140140
interleave :: [a] -> [a] -> [a]
141141
interleave [] ys = ys
142+
interleave xs [] = xs
142143
interleave (x:xs) (y:ys) = x : y : interleave xs ys
143144

144145
gen :: StdGen

containers-tests/benchmarks/Sequence.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ fakeDeleteAt i xs
226226
-- and rejoin the pieces in the opposite order.
227227
-- Finally getting the middle element forces the whole spine.
228228
shuffle :: [Int] -> S.Seq Int -> Int
229-
shuffle ps s = case S.viewl (S.drop (S.length s `div` 2) (foldl' cut s ps)) of
230-
x S.:< _ -> x
229+
shuffle ps s = S.index (foldl' cut s ps) (S.length s `div` 2)
231230
where cut xs p = let (front, back) = S.splitAt p xs in back S.>< front
232231

233232
stateReplicate :: Int -> S.Seq Char

containers-tests/containers-tests.cabal

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ common deps
4141
, template-haskell
4242

4343
common warnings
44-
ghc-options: -Werror=unused-top-binds
44+
ghc-options:
45+
-Werror=unused-top-binds
46+
-Werror=incomplete-patterns
47+
-Werror=incomplete-uni-patterns
4548

4649
common test-deps
4750
import: deps

containers-tests/tests/intmap-properties.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ prop_mergeWithKeyModel xs ys
13861386
(Nothing, Just y) -> if keep_y then Just (k, y) else Nothing
13871387
(Just x, Nothing) -> if keep_x then Just (k, x) else Nothing
13881388
(Just x, Just y) -> (\v -> (k, v)) `fmap` f k x y
1389+
(Nothing, Nothing) -> error "impossible"
13891390

13901391
-- We prevent inlining testMergeWithKey to disable the SpecConstr
13911392
-- optimalization. There are too many call patterns here so several
@@ -1951,14 +1952,18 @@ prop_maxViewWithKey m = case maxViewWithKey m of
19511952
prop_minView :: IntMap A -> Property
19521953
prop_minView m = case minView m of
19531954
Nothing -> property $ null m
1954-
Just (x,m') | ~(_,x'):xs' <- toList m ->
1955-
valid m' .&&. x == x' .&&. toList m' === xs'
1955+
Just (x,m') -> valid m' .&&. kxs === (minKey, x) : toList m'
1956+
where
1957+
kxs = toList m
1958+
minKey = minimum (fmap fst kxs)
19561959

19571960
prop_maxView :: IntMap A -> Property
19581961
prop_maxView m = case maxView m of
19591962
Nothing -> property $ null m
1960-
Just (x,m') | ~(_,x'):xs' <- toDescList m ->
1961-
valid m' .&&. x == x' .&&. toDescList m' === xs'
1963+
Just (x,m') -> valid m' .&&. kxs === (maxKey, x) : toDescList m'
1964+
where
1965+
kxs = toDescList m
1966+
maxKey = maximum (fmap fst kxs)
19621967

19631968
prop_mapEither :: Fun A (Either B C) -> IntMap A -> Property
19641969
prop_mapEither f m =

containers-tests/tests/map-properties.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ prop_mergeWithKeyModel xs ys
12421242
(Nothing, Just y) -> if keep_y then Just (k, y) else Nothing
12431243
(Just x, Nothing) -> if keep_x then Just (k, x) else Nothing
12441244
(Just x, Just y) -> (\v -> (k, v)) `fmap` f k x y
1245+
(Nothing, Nothing) -> error "impossible"
12451246

12461247
-- We prevent inlining testMergeWithKey to disable the SpecConstr
12471248
-- optimalization. There are too many call patterns here so several
@@ -1914,14 +1915,18 @@ prop_maxViewWithKey m = case maxViewWithKey m of
19141915
prop_minView :: Map Int A -> Property
19151916
prop_minView m = case minView m of
19161917
Nothing -> property $ null m
1917-
Just (x,m') | ~(_,x'):xs' <- toList m ->
1918-
valid m' .&&. x == x' .&&. toList m' === xs'
1918+
Just (x,m') -> valid m' .&&. kxs === (minKey, x) : toList m'
1919+
where
1920+
kxs = toList m
1921+
minKey = minimum (fmap fst kxs)
19191922

19201923
prop_maxView :: Map Int A -> Property
19211924
prop_maxView m = case maxView m of
19221925
Nothing -> property $ null m
1923-
Just (x,m') | ~(_,x'):xs' <- toDescList m ->
1924-
valid m' .&&. x == x' .&&. toDescList m' === xs'
1926+
Just (x,m') -> valid m' .&&. kxs === (maxKey, x) : toDescList m'
1927+
where
1928+
kxs = toDescList m
1929+
maxKey = maximum (fmap fst kxs)
19251930

19261931
prop_isSubmapOf :: Map Int A -> Map Int A -> Property
19271932
prop_isSubmapOf m1 m2 = isSubmapOf m1 m2 === all (`elem` kys) (toList m1)

0 commit comments

Comments
 (0)