Skip to content

Merge testsuites into one #351

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

Merged
merged 1 commit into from
Feb 18, 2022
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
14 changes: 14 additions & 0 deletions tests/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Main (main) where

import Test.Tasty (defaultMain, testGroup)

import qualified Regressions
import qualified Properties
import qualified Strictness

main :: IO ()
main = defaultMain $ testGroup "All"
[ Properties.tests
, Regressions.tests
, Strictness.tests
]
16 changes: 16 additions & 0 deletions tests/Properties.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Properties (tests) where

import Test.Tasty (TestTree, testGroup)

import qualified Properties.HashMapLazy
import qualified Properties.HashMapStrict
import qualified Properties.HashSet
import qualified Properties.List

tests :: TestTree
tests = testGroup "Properties"
[ Properties.HashMapLazy.tests
, Properties.HashMapStrict.tests
, Properties.HashSet.tests
, Properties.List.tests
]
22 changes: 13 additions & 9 deletions tests/HashMapProperties.hs → tests/Properties/HashMapLazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
-- | Tests for the 'Data.HashMap.Lazy' module. We test functions by
-- comparing them to @Map@ from @containers@.

module Main (main) where
#if defined(STRICT)
module Properties.HashMapStrict (tests) where
#else
module Properties.HashMapLazy (tests) where
#endif

import Control.Monad ( guard )
import qualified Data.Foldable as Foldable
Expand All @@ -25,7 +29,7 @@ import qualified Data.HashMap.Lazy as HM
import qualified Data.Map.Lazy as M
#endif
import Test.QuickCheck (Arbitrary(..), Property, (==>), (===), forAll, elements)
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
import Data.Functor.Identity (Identity (..))
import Control.Applicative (Const (..))
Expand Down Expand Up @@ -441,7 +445,13 @@ pKeys = (L.sort . M.keys) `eq` (L.sort . HM.keys)
-- * Test list

tests :: TestTree
tests = testGroup "HashMap properties"
tests =
testGroup
#if defined(STRICT)
"Data.HashMap.Strict"
#else
"Data.HashMap.Lazy"
#endif
[
-- Instances
testGroup "instances"
Expand Down Expand Up @@ -571,12 +581,6 @@ eq_ f g = (M.toAscList . f) `eq` (toAscList . g)

infix 4 `eq_`

------------------------------------------------------------------------
-- * Test harness

main :: IO ()
main = defaultMain tests

------------------------------------------------------------------------
-- * Helpers

Expand Down
5 changes: 5 additions & 0 deletions tests/Properties/HashMapStrict.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE CPP #-}

#define STRICT

#include "HashMapLazy.hs"
12 changes: 3 additions & 9 deletions tests/HashSetProperties.hs → tests/Properties/HashSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- | Tests for the 'Data.HashSet' module. We test functions by
-- comparing them to @Set@ from @containers@.

module Main (main) where
module Properties.HashSet (tests) where

import qualified Data.Foldable as Foldable
import Data.Hashable (Hashable(hashWithSalt))
Expand All @@ -12,7 +12,7 @@ import qualified Data.HashSet as S
import qualified Data.Set as Set
import Data.Ord (comparing)
import Test.QuickCheck (Arbitrary, Property, (==>), (===))
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)

-- Key type that generates more hash collisions.
Expand Down Expand Up @@ -160,7 +160,7 @@ pToList = Set.toAscList `eq` toAscList
-- * Test list

tests :: TestTree
tests = testGroup "HashSet properties"
tests = testGroup "Data.HashSet"
[
-- Instances
testGroup "instances"
Expand Down Expand Up @@ -227,12 +227,6 @@ eq_ :: (Eq a, Hashable a, Ord a)
-- equivalent
eq_ f g = (Set.toAscList . f) `eq` (toAscList . g)

------------------------------------------------------------------------
-- * Test harness

main :: IO ()
main = defaultMain tests

------------------------------------------------------------------------
-- * Helpers

Expand Down
7 changes: 2 additions & 5 deletions tests/List.hs → tests/Properties/List.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Main (main) where
module Properties.List (tests) where

import Data.HashMap.Internal.List
import Data.List (nub, sort, sortBy)
import Data.Ord (comparing)

import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
import Test.QuickCheck ((==>), (===), property, Property)

Expand Down Expand Up @@ -63,6 +63,3 @@ modelUnorderedCompareTrans xs ys zs =
pUnorderedCompare :: [Int] -> [Int] -> Property
pUnorderedCompare xs ys =
unorderedCompare compare xs ys === modelUnorderedCompare xs ys

main :: IO ()
main = defaultMain tests
10 changes: 2 additions & 8 deletions tests/Regressions.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Main where
module Regressions (tests) where

import Control.Exception (evaluate)
import Control.Monad (replicateM)
Expand All @@ -16,7 +16,7 @@ import System.Mem (performGC)
import System.Mem.Weak (mkWeakPtr, deRefWeak)
import System.Random (randomIO)
import Test.HUnit (Assertion, assert)
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
import Test.Tasty.QuickCheck (testProperty)
import Test.QuickCheck
Expand Down Expand Up @@ -135,9 +135,3 @@ tests = testGroup "Regression tests"
, testCase "issue254 lazy" issue254Lazy
, testCase "issue254 strict" issue254Strict
]

------------------------------------------------------------------------
-- * Test harness

main :: IO ()
main = defaultMain tests
12 changes: 3 additions & 9 deletions tests/Strictness.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{-# LANGUAGE CPP, FlexibleInstances, GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Main (main) where
module Strictness (tests) where

import Data.Hashable (Hashable(hashWithSalt))
import Test.ChasingBottoms.IsBottom
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
import Test.QuickCheck (Arbitrary(arbitrary), Property, (===), (.&&.))
import Test.QuickCheck.Function
Expand Down Expand Up @@ -150,7 +150,7 @@ pFromListWithValueResultStrict lst comb_lazy calc_good_raw
-- * Test list

tests :: TestTree
tests = testGroup "Strictness tests"
tests = testGroup "Strictness"
[
-- Basic interface
testGroup "HashMap.Strict"
Expand All @@ -175,12 +175,6 @@ tests = testGroup "Strictness tests"
]
]

------------------------------------------------------------------------
-- * Test harness

main :: IO ()
main = defaultMain tests

------------------------------------------------------------------------
-- * Utilities

Expand Down
103 changes: 11 additions & 92 deletions unordered-containers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -78,85 +78,23 @@ library
if flag(debug)
cpp-options: -DASSERTS

test-suite hashmap-lazy-properties
test-suite unordered-containers-tests
hs-source-dirs: tests
main-is: HashMapProperties.hs
main-is: Main.hs
type: exitcode-stdio-1.0

build-depends:
base,
containers >= 0.5.8,
hashable >= 1.0.1.1,
QuickCheck >= 2.4.0.1,
tasty >= 1.4.0.3,
tasty-quickcheck >= 0.10.1.2,
unordered-containers

default-language: Haskell2010
ghc-options: -Wall
cpp-options: -DASSERTS

test-suite hashmap-strict-properties
hs-source-dirs: tests
main-is: HashMapProperties.hs
type: exitcode-stdio-1.0

build-depends:
base,
containers >= 0.5.8,
hashable >= 1.0.1.1,
QuickCheck >= 2.4.0.1,
tasty >= 1.4.0.3,
tasty-quickcheck >= 0.10.1.2,
unordered-containers

default-language: Haskell2010
ghc-options: -Wall
cpp-options: -DASSERTS -DSTRICT

test-suite hashset-properties
hs-source-dirs: tests
main-is: HashSetProperties.hs
type: exitcode-stdio-1.0

build-depends:
base,
containers >= 0.4.2.0,
hashable >= 1.0.1.1,
QuickCheck >= 2.4.0.1,
tasty >= 1.4.0.3,
tasty-quickcheck >= 0.10.1.2,
unordered-containers

default-language: Haskell2010
ghc-options: -Wall
cpp-options: -DASSERTS

test-suite list-tests
hs-source-dirs: tests .
main-is: List.hs
other-modules:
Data.HashMap.Internal.List
type: exitcode-stdio-1.0

build-depends:
base,
containers >= 0.4,
QuickCheck >= 2.4.0.1,
tasty >= 1.4.0.3,
tasty-quickcheck >= 0.10.1.2

default-language: Haskell2010
ghc-options: -Wall
cpp-options: -DASSERTS

test-suite regressions
hs-source-dirs: tests
main-is: Regressions.hs
type: exitcode-stdio-1.0
Regressions
Properties
Properties.HashMapLazy
Properties.HashMapStrict
Properties.HashSet
Properties.List
Strictness

build-depends:
base,
ChasingBottoms,
containers >= 0.5.8,
hashable >= 1.0.1.1,
HUnit,
QuickCheck >= 2.4.0.1,
Expand All @@ -170,25 +108,6 @@ test-suite regressions
ghc-options: -Wall
cpp-options: -DASSERTS

test-suite strictness-properties
hs-source-dirs: tests
main-is: Strictness.hs
type: exitcode-stdio-1.0

build-depends:
base,
ChasingBottoms,
containers >= 0.4.2,
hashable >= 1.0.1.1,
QuickCheck >= 2.4.0.1,
tasty >= 1.4.0.3,
tasty-quickcheck >= 0.10.1.2,
unordered-containers

default-language: Haskell2010
ghc-options: -Wall
cpp-options: -DASSERTS

benchmark benchmarks
hs-source-dirs: benchmarks
main-is: Benchmarks.hs
Expand Down