Skip to content

Commit ff3d6af

Browse files
authored
Migrate from test-framework to tasty (#796)
1 parent 0b41e11 commit ff3d6af

14 files changed

+113
-154
lines changed

containers-tests/containers-tests.cabal

+39-49
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,10 @@ test-suite map-lazy-properties
266266
CPP
267267

268268
build-depends:
269-
HUnit
270-
, QuickCheck >=2.7.1
271-
, test-framework
272-
, test-framework-hunit
273-
, test-framework-quickcheck2
269+
QuickCheck >=2.7.1
270+
, tasty
271+
, tasty-hunit
272+
, tasty-quickcheck
274273
, transformers
275274

276275
test-suite map-strict-properties
@@ -291,11 +290,10 @@ test-suite map-strict-properties
291290
CPP
292291

293292
build-depends:
294-
HUnit
295-
, QuickCheck >=2.7.1
296-
, test-framework
297-
, test-framework-hunit
298-
, test-framework-quickcheck2
293+
QuickCheck >=2.7.1
294+
, tasty
295+
, tasty-hunit
296+
, tasty-quickcheck
299297
, transformers
300298

301299
test-suite bitqueue-properties
@@ -311,9 +309,8 @@ test-suite bitqueue-properties
311309

312310
build-depends: containers-tests
313311
build-depends:
314-
QuickCheck >=2.7.1
315-
, test-framework
316-
, test-framework-quickcheck2
312+
tasty
313+
, tasty-quickcheck
317314

318315
test-suite set-properties
319316
default-language: Haskell2010
@@ -332,11 +329,10 @@ test-suite set-properties
332329

333330
build-depends: containers-tests
334331
build-depends:
335-
HUnit
336-
, QuickCheck >=2.7.1
337-
, test-framework
338-
, test-framework-hunit
339-
, test-framework-quickcheck2
332+
QuickCheck >=2.7.1
333+
, tasty
334+
, tasty-hunit
335+
, tasty-quickcheck
340336
, transformers
341337

342338
if impl(ghc >= 8.6)
@@ -363,11 +359,10 @@ test-suite intmap-lazy-properties
363359
CPP
364360

365361
build-depends:
366-
HUnit
367-
, QuickCheck >=2.7.1
368-
, test-framework
369-
, test-framework-hunit
370-
, test-framework-quickcheck2
362+
QuickCheck >=2.7.1
363+
, tasty
364+
, tasty-hunit
365+
, tasty-quickcheck
371366

372367
test-suite intmap-strict-properties
373368
default-language: Haskell2010
@@ -389,11 +384,10 @@ test-suite intmap-strict-properties
389384

390385
build-depends: containers-tests
391386
build-depends:
392-
HUnit
393-
, QuickCheck >=2.7.1
394-
, test-framework
395-
, test-framework-hunit
396-
, test-framework-quickcheck2
387+
QuickCheck >=2.7.1
388+
, tasty
389+
, tasty-hunit
390+
, tasty-quickcheck
397391

398392
test-suite intset-properties
399393
default-language: Haskell2010
@@ -413,11 +407,9 @@ test-suite intset-properties
413407

414408
build-depends: containers-tests
415409
build-depends:
416-
HUnit
417-
, QuickCheck >=2.7.1
418-
, test-framework
419-
, test-framework-hunit
420-
, test-framework-quickcheck2
410+
tasty
411+
, tasty-hunit
412+
, tasty-quickcheck
421413

422414
test-suite seq-properties
423415
default-language: Haskell2010
@@ -437,8 +429,8 @@ test-suite seq-properties
437429

438430
build-depends:
439431
QuickCheck >=2.7.1
440-
, test-framework
441-
, test-framework-quickcheck2
432+
, tasty
433+
, tasty-quickcheck
442434
, transformers
443435

444436
test-suite tree-properties
@@ -459,8 +451,8 @@ test-suite tree-properties
459451

460452
build-depends:
461453
QuickCheck >=2.7.1
462-
, test-framework
463-
, test-framework-quickcheck2
454+
, tasty
455+
, tasty-quickcheck
464456
, transformers
465457

466458
test-suite map-strictness-properties
@@ -474,11 +466,10 @@ test-suite map-strictness-properties
474466
, base >=4.6 && <5
475467
, ChasingBottoms
476468
, deepseq >=1.2 && <1.5
477-
, HUnit
478469
, QuickCheck >=2.7.1
479-
, test-framework >=0.3.3
480-
, test-framework-quickcheck2 >=0.2.9
481-
, test-framework-hunit
470+
, tasty
471+
, tasty-quickcheck
472+
, tasty-hunit
482473

483474
ghc-options: -Wall
484475
other-extensions:
@@ -509,11 +500,10 @@ test-suite intmap-strictness-properties
509500
, base >=4.6 && <5
510501
, ChasingBottoms
511502
, deepseq >=1.2 && <1.5
512-
, HUnit
513503
, QuickCheck >=2.7.1
514-
, test-framework >=0.3.3
515-
, test-framework-quickcheck2 >=0.2.9
516-
, test-framework-hunit
504+
, tasty
505+
, tasty-quickcheck
506+
, tasty-hunit
517507

518508
ghc-options: -Wall
519509

@@ -542,8 +532,8 @@ test-suite intset-strictness-properties
542532
, ChasingBottoms
543533
, deepseq >=1.2 && <1.5
544534
, QuickCheck >=2.7.1
545-
, test-framework >=0.3.3
546-
, test-framework-quickcheck2 >=0.2.9
535+
, tasty
536+
, tasty-quickcheck
547537

548538
ghc-options: -Wall
549539

@@ -564,7 +554,7 @@ test-suite listutils-properties
564554
, ChasingBottoms
565555
, deepseq >=1.2 && <1.5
566556
, QuickCheck >=2.7.1
567-
, test-framework >=0.3.3
568-
, test-framework-quickcheck2 >=0.2.9
557+
, tasty
558+
, tasty-quickcheck
569559

570560
ghc-options: -Wall

containers-tests/tests/IntMapValidity.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module IntMapValidity (valid) where
22

33
import Data.Bits (xor, (.&.))
44
import Data.IntMap.Internal
5-
import Test.QuickCheck (Property, counterexample, property, (.&&.))
5+
import Test.Tasty.QuickCheck (Property, counterexample, property, (.&&.))
66
import Utils.Containers.Internal.BitUtil (bitcount)
77

88
{--------------------------------------------------------------------

containers-tests/tests/IntSetValidity.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module IntSetValidity (valid) where
33

44
import Data.Bits (xor, (.&.))
55
import Data.IntSet.Internal
6-
import Test.QuickCheck (Property, counterexample, property, (.&&.))
6+
import Test.Tasty.QuickCheck (Property, counterexample, property, (.&&.))
77
import Utils.Containers.Internal.BitUtil (bitcount)
88

99
{--------------------------------------------------------------------

containers-tests/tests/bitqueue-properties.hs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import Control.Applicative ((<$>))
66
#endif
77
import qualified Data.List as List
8-
import Test.Framework
9-
import Test.Framework.Providers.QuickCheck2
10-
import Test.QuickCheck
8+
import Test.Tasty
9+
import Test.Tasty.QuickCheck
1110
import Utils.Containers.Internal.BitUtil (wordSize)
1211
import Utils.Containers.Internal.BitQueue
1312
( BitQueue
@@ -19,9 +18,9 @@ import Utils.Containers.Internal.BitQueue
1918
default (Int)
2019

2120
main :: IO ()
22-
main = defaultMain $ map testNum [0..(wordSize - 2)]
21+
main = defaultMain $ testGroup "bitqueue-properties" $ map testNum [0..(wordSize - 2)]
2322

24-
testNum :: Int -> Test
23+
testNum :: Int -> TestTree
2524
testNum n = testProperty ("Size "++show n) (prop_n n)
2625

2726
prop_n :: Int -> Gen Bool

containers-tests/tests/intmap-properties.hs

+5-17
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ import qualified Prelude (map)
2727
import Data.List (nub,sort)
2828
import qualified Data.List as List
2929
import qualified Data.IntSet as IntSet
30-
import Test.Framework
31-
import Test.Framework.Providers.HUnit
32-
import Test.Framework.Providers.QuickCheck2
33-
import Test.HUnit hiding (Test, Testable)
34-
import Test.QuickCheck
35-
import Test.QuickCheck.Function (Fun(..), apply)
30+
import Test.Tasty
31+
import Test.Tasty.HUnit
32+
import Test.Tasty.QuickCheck
33+
import Test.QuickCheck.Function (apply)
3634
import Test.QuickCheck.Poly (A, B, C)
3735

3836
default (Int)
3937

4038
main :: IO ()
41-
main = defaultMain
39+
main = defaultMain $ testGroup "intmap-properties"
4240
[
4341
testCase "index" test_index
4442
, testCase "index_lookup" test_index_lookup
@@ -237,16 +235,6 @@ type UMap = IntMap ()
237235
type IMap = IntMap Int
238236
type SMap = IntMap String
239237

240-
----------------------------------------------------------------
241-
242-
tests :: [Test]
243-
tests = [ testGroup "Test Case" [
244-
]
245-
, testGroup "Property Test" [
246-
]
247-
]
248-
249-
250238
----------------------------------------------------------------
251239
-- Unit tests
252240
----------------------------------------------------------------

containers-tests/tests/intmap-strictness.hs

+13-15
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
module Main (main) where
55

66
import Test.ChasingBottoms.IsBottom
7-
import Test.Framework (Test, TestName, defaultMain, testGroup)
8-
import Test.Framework.Providers.QuickCheck2 (testProperty)
9-
import Test.QuickCheck (Arbitrary(arbitrary))
7+
import Test.Tasty (TestTree, TestName, defaultMain, testGroup)
8+
import Test.Tasty.HUnit
9+
import Test.Tasty.QuickCheck (testProperty, Arbitrary(arbitrary), Fun)
1010
#if __GLASGOW_HASKELL__ >= 806
11-
import Test.QuickCheck (Property)
11+
import Test.Tasty.QuickCheck (Property)
1212
#endif
13-
import Test.QuickCheck.Function (Fun(..), apply)
14-
import Test.Framework.Providers.HUnit
15-
import Test.HUnit hiding (Test)
13+
import Test.QuickCheck.Function (apply)
1614

1715
import Data.IntMap.Strict (IntMap)
1816
import qualified Data.IntMap.Strict as M
@@ -126,7 +124,7 @@ pStrictFoldl' m = whnfHasNoThunks (M.foldl' (flip (:)) [] m)
126124
-- in most cases. An exception is `L.fromListWith const`, which cannot
127125
-- evaluate the `const` calls.
128126

129-
tExtraThunksM :: Test
127+
tExtraThunksM :: TestTree
130128
tExtraThunksM = testGroup "IntMap.Strict - extra thunks" $
131129
if not isUnitSupported then [] else
132130
-- for strict maps, all the values should be evaluated to ()
@@ -141,14 +139,14 @@ tExtraThunksM = testGroup "IntMap.Strict - extra thunks" $
141139
]
142140
where
143141
m0 = M.singleton 42 ()
144-
check :: TestName -> IntMap () -> Test
142+
check :: TestName -> IntMap () -> TestTree
145143
check n m = testCase n $ case M.lookup 42 m of
146144
Just v -> assertBool msg (isUnit v)
147-
_ -> assertString "key not found"
145+
_ -> assertBool "key not found" False
148146
where
149147
msg = "too lazy -- expected fully evaluated ()"
150148

151-
tExtraThunksL :: Test
149+
tExtraThunksL :: TestTree
152150
tExtraThunksL = testGroup "IntMap.Lazy - extra thunks" $
153151
if not isUnitSupported then [] else
154152
-- for lazy maps, the *With functions should leave `const () ()` thunks,
@@ -164,18 +162,18 @@ tExtraThunksL = testGroup "IntMap.Lazy - extra thunks" $
164162
]
165163
where
166164
m0 = L.singleton 42 ()
167-
check :: TestName -> Bool -> L.IntMap () -> Test
165+
check :: TestName -> Bool -> L.IntMap () -> TestTree
168166
check n e m = testCase n $ case L.lookup 42 m of
169167
Just v -> assertBool msg (e == isUnit v)
170-
_ -> assertString "key not found"
168+
_ -> assertBool "key not found" False
171169
where
172170
msg | e = "too lazy -- expected fully evaluated ()"
173171
| otherwise = "too strict -- expected a thunk"
174172

175173
------------------------------------------------------------------------
176174
-- * Test list
177175

178-
tests :: [Test]
176+
tests :: [TestTree]
179177
tests =
180178
[
181179
-- Basic interface
@@ -214,7 +212,7 @@ tests =
214212
-- * Test harness
215213

216214
main :: IO ()
217-
main = defaultMain tests
215+
main = defaultMain $ testGroup "intmap-strictness" tests
218216

219217
------------------------------------------------------------------------
220218
-- * Utilities

containers-tests/tests/intset-properties.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import Data.Monoid (mempty)
99
import qualified Data.Set as Set
1010
import IntSetValidity (valid)
1111
import Prelude hiding (lookup, null, map, filter, foldr, foldl)
12-
import Test.Framework
13-
import Test.Framework.Providers.HUnit
14-
import Test.Framework.Providers.QuickCheck2
15-
import Test.HUnit hiding (Test, Testable)
16-
import Test.QuickCheck hiding ((.&.))
12+
import Test.Tasty
13+
import Test.Tasty.HUnit
14+
import Test.Tasty.QuickCheck hiding ((.&.))
1715

1816
main :: IO ()
19-
main = defaultMain [ testCase "lookupLT" test_lookupLT
17+
main = defaultMain $ testGroup "intset-properties"
18+
[ testCase "lookupLT" test_lookupLT
2019
, testCase "lookupGT" test_lookupGT
2120
, testCase "lookupLE" test_lookupLE
2221
, testCase "lookupGE" test_lookupGE

containers-tests/tests/intset-strictness.hs

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ module Main (main) where
77
import Prelude hiding (foldl)
88

99
import Test.ChasingBottoms.IsBottom
10-
import Test.Framework (Test, defaultMain, testGroup)
11-
import Test.Framework.Providers.QuickCheck2 (testProperty)
12-
import Test.QuickCheck (Arbitrary (..))
10+
import Test.Tasty (TestTree, defaultMain, testGroup)
11+
import Test.Tasty.QuickCheck (testProperty, Arbitrary (..))
1312
#if __GLASGOW_HASKELL__ >= 806
14-
import Test.QuickCheck (Property)
13+
import Test.Tasty.QuickCheck (Property)
1514
#endif
1615

1716
import Data.IntSet
@@ -52,9 +51,8 @@ pStrictFoldl' m = whnfHasNoThunks (foldl' (flip (:)) [] m)
5251
------------------------------------------------------------------------
5352
-- * Test list
5453

55-
tests :: [Test]
54+
tests :: TestTree
5655
tests =
57-
[
5856
-- Basic interface
5957
testGroup "IntSet"
6058
[ testProperty "foldl is lazy in accumulator" pFoldlAccLazy
@@ -63,7 +61,6 @@ tests =
6361
, testProperty "strict foldl'" pStrictFoldl'
6462
#endif
6563
]
66-
]
6764

6865
------------------------------------------------------------------------
6966
-- * Test harness

0 commit comments

Comments
 (0)