Skip to content

Commit 7f4fb90

Browse files
committed
Removed test-strict-mvar
Move `IO` tests to `io-classes` and `IOSim` tests to `io-sim`.
1 parent 54fcfe5 commit 7f4fb90

File tree

13 files changed

+121
-345
lines changed

13 files changed

+121
-345
lines changed

.github/workflows/haskell.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
run: |
8888
cabal build --only-dependencies io-classes
8989
cabal build --only-dependencies io-sim
90-
cabal build --only-dependencies test-strict-mvar
9190
9291
- uses: actions/cache/save@v4
9392
name: "Save cabal store"
@@ -108,5 +107,5 @@ jobs:
108107
- name: io-classes:si-timers [test]
109108
run: cabal run io-classes:test-si-timers
110109

111-
- name: test-strict-mvar [test]
112-
run: cabal run test-strict-mvar
110+
- name: io-classes:strict-mvar [test]
111+
run: cabal run io-classes:test-strict-mvar

cabal.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ index-state: hackage.haskell.org 2024-05-17T03:42:00Z
33
packages: ./io-sim
44
./io-classes
55
./io-classes-mtl
6-
./test-strict-mvar
76

87
package io-sim
98
flags: +asserts

io-classes/io-classes.cabal

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,42 @@ library si-timers
183183
if flag(asserts)
184184
ghc-options: -fno-ignore-asserts
185185

186+
library testlib
187+
import: warnings
188+
visibility: public
189+
hs-source-dirs: test
190+
exposed-modules: Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
191+
default-language: Haskell2010
192+
default-extensions: ImportQualifiedPost
193+
build-depends: base >=4.9 && <4.21,
194+
nothunks,
195+
QuickCheck,
196+
io-classes:strict-mvar
197+
if flag(asserts)
198+
ghc-options: -fno-ignore-asserts
199+
200+
test-suite test-strict-mvar
201+
type: exitcode-stdio-1.0
202+
hs-source-dirs: strict-mvar/test
203+
main-is: Main.hs
204+
205+
default-language: Haskell2010
206+
default-extensions: ImportQualifiedPost
207+
build-depends: base,
208+
QuickCheck,
209+
tasty,
210+
tasty-quickcheck,
211+
io-classes:testlib
212+
213+
ghc-options: -Wall
214+
-Wno-unticked-promoted-constructors
215+
-Wcompat
216+
-Wincomplete-uni-patterns
217+
-Wincomplete-record-updates
218+
-Wpartial-fields
219+
-Widentities
220+
-fno-ignore-asserts
221+
186222
-- Since `io-sim` depends on `si-times` (`io-sim` depends on `Time`) some tests of
187223
-- are in `io-sim:test`: this is a good enough reason to pull `io-sim:test`
188224
-- into a seprate package.

io-classes/strict-mvar/test/Main.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Main where
2+
3+
import Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
4+
5+
import Test.QuickCheck.Monadic (monadicIO)
6+
import Test.Tasty
7+
import Test.Tasty.QuickCheck
8+
9+
10+
main :: IO ()
11+
main = defaultMain $ testGroup "strict-mvar" [tests]
12+
13+
tests :: TestTree
14+
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict"
15+
[ testGroup "WHNF"
16+
[ testGroup "IO"
17+
[ testProperty "prop_newMVar" $
18+
monadicIO .: prop_newMVar
19+
, testProperty "prop_putMVar" $
20+
monadicIO .: prop_putMVar
21+
, testProperty "prop_swapMVar" $
22+
monadicIO .: prop_swapMVar
23+
, testProperty "prop_tryPutMVar" $
24+
monadicIO .: prop_tryPutMVar
25+
, testProperty "prop_modifyMVar_" $
26+
monadicIO .: prop_modifyMVar_
27+
, testProperty "prop_modifyMVar" $
28+
monadicIO .: prop_modifyMVar
29+
, testProperty "prop_modifyMVarMasked_" $
30+
monadicIO .: prop_modifyMVarMasked_
31+
, testProperty "prop_modifyMVarMasked" $
32+
monadicIO .: prop_modifyMVarMasked
33+
]
34+
]
35+
]

test-strict-mvar/test/Test/Control/Concurrent/Class/MonadMVar/Strict/WHNF.hs renamed to io-classes/test/Test/Control/Concurrent/Class/MonadMVar/Strict/WHNF.hs

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,24 @@
22

33
-- | Test whether functions on 'StrictMVar's correctly force values to WHNF
44
-- before they are put inside the 'StrictMVar'.
5-
module Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF (tests) where
5+
module Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
6+
( prop_newMVar
7+
, prop_putMVar
8+
, prop_swapMVar
9+
, prop_tryPutMVar
10+
, prop_modifyMVar_
11+
, prop_modifyMVar
12+
, prop_modifyMVarMasked_
13+
, prop_modifyMVarMasked
14+
, (.:)
15+
) where
616

717
import Control.Concurrent.Class.MonadMVar.Strict
818
import Control.Monad (void)
9-
import Control.Monad.IOSim (monadicIOSim_)
1019
import Data.Typeable (Typeable)
1120
import NoThunks.Class (OnlyCheckWhnf (OnlyCheckWhnf), unsafeNoThunks)
12-
import Test.QuickCheck.Monadic (PropertyM, monadicIO, monitor, run)
13-
import Test.Tasty (TestTree, testGroup)
14-
import Test.Tasty.QuickCheck (Fun, applyFun, counterexample, testProperty)
15-
16-
{-------------------------------------------------------------------------------
17-
Main test tree
18-
-------------------------------------------------------------------------------}
19-
20-
tests :: TestTree
21-
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict" [
22-
testGroup "WHNF" [
23-
testGroup "IO" [
24-
testProperty "prop_newMVar" $
25-
monadicIO .: prop_newMVar
26-
, testProperty "prop_putMVar" $
27-
monadicIO .: prop_putMVar
28-
, testProperty "prop_swapMVar" $
29-
monadicIO .: prop_swapMVar
30-
, testProperty "prop_tryPutMVar" $
31-
monadicIO .: prop_tryPutMVar
32-
, testProperty "prop_modifyMVar_" $
33-
monadicIO .: prop_modifyMVar_
34-
, testProperty "prop_modifyMVar" $
35-
monadicIO .: prop_modifyMVar
36-
, testProperty "prop_modifyMVarMasked_" $
37-
monadicIO .: prop_modifyMVarMasked_
38-
, testProperty "prop_modifyMVarMasked" $
39-
monadicIO .: prop_modifyMVarMasked
40-
]
41-
, testGroup "IOSim" [
42-
testProperty "prop_newMVar" $ \x f ->
43-
monadicIOSim_ $ prop_newMVar x f
44-
, testProperty "prop_putMVar" $ \x f ->
45-
monadicIOSim_ $ prop_putMVar x f
46-
, testProperty "prop_swapMVar" $ \x f ->
47-
monadicIOSim_ $ prop_swapMVar x f
48-
, testProperty "prop_tryPutMVar" $ \x f ->
49-
monadicIOSim_ $ prop_tryPutMVar x f
50-
, testProperty "prop_modifyMVar_" $ \x f ->
51-
monadicIOSim_ $ prop_modifyMVar_ x f
52-
, testProperty "prop_modifyMVar" $ \x f ->
53-
monadicIOSim_ $ prop_modifyMVar x f
54-
, testProperty "prop_modifyMVarMasked_" $ \x f ->
55-
monadicIOSim_ $ prop_modifyMVarMasked_ x f
56-
, testProperty "prop_modifyMVarMasked" $ \x f ->
57-
monadicIOSim_ $ prop_modifyMVarMasked x f
58-
]
59-
]
60-
]
21+
import Test.QuickCheck
22+
import Test.QuickCheck.Monadic (PropertyM, monitor, run)
6123

6224
{-------------------------------------------------------------------------------
6325
Utilities

io-sim/io-sim.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ test-suite test
9999
hs-source-dirs: test
100100
main-is: Main.hs
101101
other-modules: Test.Control.Concurrent.Class.MonadMVar
102+
Test.Control.Concurrent.Class.MonadMVar.Strict
102103
Test.Control.Monad.STM
103104
Test.Control.Monad.Utils
104105
Test.Control.Monad.IOSim
@@ -108,7 +109,7 @@ test-suite test
108109
build-depends: base,
109110
array,
110111
containers,
111-
io-classes:{io-classes,strict-stm,si-timers},
112+
io-classes:{io-classes,strict-stm,si-timers,testlib},
112113
io-sim,
113114
QuickCheck,
114115
tasty,

io-sim/test/Main.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Main (main) where
33
import Test.Tasty
44

55
import Test.Control.Concurrent.Class.MonadMVar qualified (tests)
6+
import Test.Control.Concurrent.Class.MonadMVar.Strict qualified (tests)
67
import Test.Control.Monad.IOSim qualified (tests)
78
import Test.Control.Monad.IOSimPOR qualified (tests)
89

@@ -13,6 +14,7 @@ tests :: TestTree
1314
tests =
1415
testGroup "io-sim-tests"
1516
[ Test.Control.Concurrent.Class.MonadMVar.tests
17+
, Test.Control.Concurrent.Class.MonadMVar.Strict.tests
1618
, Test.Control.Monad.IOSim.tests
1719
, Test.Control.Monad.IOSimPOR.tests
1820
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module Test.Control.Concurrent.Class.MonadMVar.Strict where
2+
3+
import Control.Monad.IOSim
4+
import Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
5+
6+
import Test.Tasty
7+
import Test.Tasty.QuickCheck
8+
9+
tests :: TestTree
10+
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict"
11+
[ testGroup "WHNF"
12+
[ testGroup "IOSIM"
13+
[ testProperty "prop_newMVar" $ \x f ->
14+
monadicIOSim_ $ prop_newMVar x f
15+
, testProperty "prop_putMVar" $ \x f ->
16+
monadicIOSim_ $ prop_putMVar x f
17+
, testProperty "prop_swapMVar" $ \x f ->
18+
monadicIOSim_ $ prop_swapMVar x f
19+
, testProperty "prop_tryPutMVar" $ \x f ->
20+
monadicIOSim_ $ prop_tryPutMVar x f
21+
, testProperty "prop_modifyMVar_" $ \x f ->
22+
monadicIOSim_ $ prop_modifyMVar_ x f
23+
, testProperty "prop_modifyMVar" $ \x f ->
24+
monadicIOSim_ $ prop_modifyMVar x f
25+
, testProperty "prop_modifyMVarMasked_" $ \x f ->
26+
monadicIOSim_ $ prop_modifyMVarMasked_ x f
27+
, testProperty "prop_modifyMVarMasked" $ \x f ->
28+
monadicIOSim_ $ prop_modifyMVarMasked x f
29+
]
30+
]
31+
]

test-strict-mvar/CHANGELOG.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)