Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on unused-top-binds in tests #1030

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions containers-tests/containers-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ common deps
, deepseq >=1.2 && <1.6
, template-haskell

common warnings
ghc-options: -Werror=unused-top-binds

common test-deps
import: deps
build-depends:
Expand Down Expand Up @@ -140,39 +143,39 @@ library
-----------------------------

benchmark intmap-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: IntMap.hs
ghc-options: -O2

benchmark intset-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: IntSet.hs
ghc-options: -O2

benchmark map-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: Map.hs
ghc-options: -O2

benchmark tree-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: Tree.hs
ghc-options: -O2

benchmark sequence-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
Expand All @@ -183,15 +186,15 @@ benchmark sequence-benchmarks
, transformers

benchmark set-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
main-is: Set.hs
ghc-options: -O2

benchmark graph-benchmarks
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks
Expand All @@ -201,7 +204,7 @@ benchmark graph-benchmarks
random >=0 && <1.2

benchmark set-operations-intmap
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/SetOperations
Expand All @@ -210,7 +213,7 @@ benchmark set-operations-intmap
ghc-options: -O2

benchmark set-operations-intset
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/SetOperations
Expand All @@ -219,7 +222,7 @@ benchmark set-operations-intset
ghc-options: -O2

benchmark set-operations-map
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/SetOperations
Expand All @@ -228,7 +231,7 @@ benchmark set-operations-map
ghc-options: -O2

benchmark set-operations-set
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/SetOperations
Expand All @@ -237,7 +240,7 @@ benchmark set-operations-set
ghc-options: -O2

benchmark lookupge-intmap
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/LookupGE
Expand All @@ -246,7 +249,7 @@ benchmark lookupge-intmap
build-depends: containers-tests

benchmark lookupge-map
import: benchmark-deps
import: benchmark-deps, warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmarks/LookupGE
Expand All @@ -263,7 +266,7 @@ benchmark lookupge-map
-- plus the testing stuff.

test-suite map-lazy-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: map-properties.hs
Expand All @@ -275,7 +278,7 @@ test-suite map-lazy-properties
CPP

test-suite map-strict-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: map-properties.hs
Expand All @@ -288,7 +291,7 @@ test-suite map-strict-properties
CPP

test-suite bitqueue-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: bitqueue-properties.hs
Expand All @@ -299,7 +302,7 @@ test-suite bitqueue-properties
CPP

test-suite set-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: set-properties.hs
Expand All @@ -317,7 +320,7 @@ test-suite set-properties
Utils.NoThunks

test-suite intmap-lazy-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: intmap-properties.hs
Expand All @@ -330,7 +333,7 @@ test-suite intmap-lazy-properties
CPP

test-suite intmap-strict-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: intmap-properties.hs
Expand All @@ -344,7 +347,7 @@ test-suite intmap-strict-properties
CPP

test-suite intset-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: intset-properties.hs
Expand All @@ -357,7 +360,7 @@ test-suite intset-properties
CPP

test-suite seq-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: seq-properties.hs
Expand All @@ -369,7 +372,7 @@ test-suite seq-properties
CPP

test-suite tree-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: tree-properties.hs
Expand All @@ -381,15 +384,15 @@ test-suite tree-properties
CPP

test-suite graph-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: graph-properties.hs
type: exitcode-stdio-1.0
ghc-options: -O2

test-suite map-strictness-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: map-strictness.hs
Expand All @@ -412,7 +415,7 @@ test-suite map-strictness-properties
Utils.NoThunks

test-suite intmap-strictness-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: intmap-strictness.hs
Expand All @@ -436,7 +439,7 @@ test-suite intmap-strictness-properties
Utils.NoThunks

test-suite intset-strictness-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: intset-strictness.hs
Expand All @@ -457,7 +460,7 @@ test-suite intset-strictness-properties
Utils.NoThunks

test-suite listutils-properties
import: test-deps
import: test-deps, warnings
default-language: Haskell2010
hs-source-dirs: tests
main-is: listutils-properties.hs
Expand Down
7 changes: 0 additions & 7 deletions containers-tests/tests/intmap-properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,6 @@ main = defaultMain $ testGroup "intmap-properties"
, testProperty "isSubmapOfBy" prop_isSubmapOfBy
]

apply2 :: Fun (a, b) c -> a -> b -> c
apply2 f a b = apply f (a, b)

apply3 :: Fun (a, b, c) d -> a -> b -> c -> d
apply3 f a b c = apply f (a, b, c)


{--------------------------------------------------------------------
Arbitrary, reasonably balanced trees
--------------------------------------------------------------------}
Expand Down
10 changes: 9 additions & 1 deletion containers-tests/tests/intset-properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ main = defaultMain $ testGroup "intset-properties"
, testProperty "prop_foldL" prop_foldL
, testProperty "prop_foldL'" prop_foldL'
, testProperty "prop_map" prop_map
, testProperty "prop_mapMonotonicId" prop_mapMonotonicId
, testProperty "prop_mapMonotonicLinear" prop_mapMonotonicLinear
, testProperty "prop_maxView" prop_maxView
, testProperty "prop_minView" prop_minView
, testProperty "prop_split" prop_split
Expand Down Expand Up @@ -389,9 +391,15 @@ prop_mapMonotonicId :: IntSet -> Property
prop_mapMonotonicId s = mapMonotonic id s === map id s

prop_mapMonotonicLinear :: Positive Int -> Int -> IntSet -> Property
prop_mapMonotonicLinear (Positive a) b s = mapMonotonic f s === map f s
prop_mapMonotonicLinear (Positive a) b s =
all ok (toList s) ==>
mapMonotonic f s === map f s
where
f x = a*x + b
ok x = -- must not overflow
fromIntegral (minBound :: Int) <= y && y <= fromIntegral (maxBound :: Int)
where
y = fromIntegral a * fromIntegral x + fromIntegral b :: Integer

prop_maxView :: IntSet -> Bool
prop_maxView s = case maxView s of
Expand Down
3 changes: 1 addition & 2 deletions containers-tests/tests/map-properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ mkArb step n
-- A type with a peculiar Eq instance designed to make sure keys
-- come from where they're supposed to.
data OddEq a = OddEq a Bool deriving (Show)
getOddEq :: OddEq a -> (a, Bool)
getOddEq (OddEq a b) = (a, b)

instance Arbitrary a => Arbitrary (OddEq a) where
arbitrary = OddEq <$> arbitrary <*> arbitrary
instance Eq a => Eq (OddEq a) where
Expand Down
6 changes: 2 additions & 4 deletions containers-tests/tests/seq-properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,8 @@ prop_sort :: Seq OrdA -> Bool
prop_sort xs =
toList' (sort xs) ~= Data.List.sort (toList xs)

data UnstableOrd = UnstableOrd
{ ordKey :: OrdA
, _ignored :: A
} deriving (Show)
data UnstableOrd = UnstableOrd OrdA A
deriving (Show)

instance Eq UnstableOrd where
x == y = compare x y == EQ
Expand Down