Skip to content

Commit

Permalink
Removed test-strict-mvar
Browse files Browse the repository at this point in the history
Move `IO` tests to `io-classes` and `IOSim` tests to `io-sim`.
  • Loading branch information
coot committed Jul 1, 2024
1 parent f3e52e5 commit cb39dbc
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 345 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
run: |
cabal build --only-dependencies io-classes
cabal build --only-dependencies io-sim
cabal build --only-dependencies test-strict-mvar
- uses: actions/cache/save@v4
name: "Save cabal store"
Expand All @@ -108,5 +107,5 @@ jobs:
- name: io-classes:si-timers [test]
run: cabal run io-classes:test-si-timers

- name: test-strict-mvar [test]
run: cabal run test-strict-mvar
- name: io-classes:strict-mvar [test]
run: cabal run io-classes:test-strict-mvar
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ index-state: hackage.haskell.org 2024-05-17T03:42:00Z
packages: ./io-sim
./io-classes
./io-classes-mtl
./test-strict-mvar

package io-sim
flags: +asserts
Expand Down
36 changes: 36 additions & 0 deletions io-classes/io-classes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,42 @@ library si-timers
if flag(asserts)
ghc-options: -fno-ignore-asserts

library testlib
import: warnings
visibility: public
hs-source-dirs: test
exposed-modules: Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
default-language: Haskell2010
default-extensions: ImportQualifiedPost
build-depends: base >=4.9 && <4.20,
nothunks,
QuickCheck,
io-classes:strict-mvar
if flag(asserts)
ghc-options: -fno-ignore-asserts

test-suite test-strict-mvar
type: exitcode-stdio-1.0
hs-source-dirs: strict-mvar/test
main-is: Main.hs

default-language: Haskell2010
default-extensions: ImportQualifiedPost
build-depends: base,
QuickCheck,
tasty,
tasty-quickcheck,
io-classes:testlib

ghc-options: -Wall
-Wno-unticked-promoted-constructors
-Wcompat
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wpartial-fields
-Widentities
-fno-ignore-asserts

-- Since `io-sim` depends on `si-times` (`io-sim` depends on `Time`) some tests of
-- are in `io-sim:test`: this is a good enough reason to pull `io-sim:test`
-- into a seprate package.
Expand Down
35 changes: 35 additions & 0 deletions io-classes/strict-mvar/test/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Main where

import Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF

import Test.QuickCheck.Monadic (monadicIO)
import Test.Tasty
import Test.Tasty.QuickCheck


main :: IO ()
main = defaultMain $ testGroup "strict-mvar" [tests]

tests :: TestTree
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict"
[ testGroup "WHNF"
[ testGroup "IO"
[ testProperty "prop_newMVar" $
monadicIO .: prop_newMVar
, testProperty "prop_putMVar" $
monadicIO .: prop_putMVar
, testProperty "prop_swapMVar" $
monadicIO .: prop_swapMVar
, testProperty "prop_tryPutMVar" $
monadicIO .: prop_tryPutMVar
, testProperty "prop_modifyMVar_" $
monadicIO .: prop_modifyMVar_
, testProperty "prop_modifyMVar" $
monadicIO .: prop_modifyMVar
, testProperty "prop_modifyMVarMasked_" $
monadicIO .: prop_modifyMVarMasked_
, testProperty "prop_modifyMVarMasked" $
monadicIO .: prop_modifyMVarMasked
]
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,24 @@

-- | Test whether functions on 'StrictMVar's correctly force values to WHNF
-- before they are put inside the 'StrictMVar'.
module Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF (tests) where
module Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF
( prop_newMVar
, prop_putMVar
, prop_swapMVar
, prop_tryPutMVar
, prop_modifyMVar_
, prop_modifyMVar
, prop_modifyMVarMasked_
, prop_modifyMVarMasked
, (.:)
) where

import Control.Concurrent.Class.MonadMVar.Strict
import Control.Monad (void)
import Control.Monad.IOSim (monadicIOSim_)
import Data.Typeable (Typeable)
import NoThunks.Class (OnlyCheckWhnf (OnlyCheckWhnf), unsafeNoThunks)
import Test.QuickCheck.Monadic (PropertyM, monadicIO, monitor, run)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (Fun, applyFun, counterexample, testProperty)

{-------------------------------------------------------------------------------
Main test tree
-------------------------------------------------------------------------------}

tests :: TestTree
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict" [
testGroup "WHNF" [
testGroup "IO" [
testProperty "prop_newMVar" $
monadicIO .: prop_newMVar
, testProperty "prop_putMVar" $
monadicIO .: prop_putMVar
, testProperty "prop_swapMVar" $
monadicIO .: prop_swapMVar
, testProperty "prop_tryPutMVar" $
monadicIO .: prop_tryPutMVar
, testProperty "prop_modifyMVar_" $
monadicIO .: prop_modifyMVar_
, testProperty "prop_modifyMVar" $
monadicIO .: prop_modifyMVar
, testProperty "prop_modifyMVarMasked_" $
monadicIO .: prop_modifyMVarMasked_
, testProperty "prop_modifyMVarMasked" $
monadicIO .: prop_modifyMVarMasked
]
, testGroup "IOSim" [
testProperty "prop_newMVar" $ \x f ->
monadicIOSim_ $ prop_newMVar x f
, testProperty "prop_putMVar" $ \x f ->
monadicIOSim_ $ prop_putMVar x f
, testProperty "prop_swapMVar" $ \x f ->
monadicIOSim_ $ prop_swapMVar x f
, testProperty "prop_tryPutMVar" $ \x f ->
monadicIOSim_ $ prop_tryPutMVar x f
, testProperty "prop_modifyMVar_" $ \x f ->
monadicIOSim_ $ prop_modifyMVar_ x f
, testProperty "prop_modifyMVar" $ \x f ->
monadicIOSim_ $ prop_modifyMVar x f
, testProperty "prop_modifyMVarMasked_" $ \x f ->
monadicIOSim_ $ prop_modifyMVarMasked_ x f
, testProperty "prop_modifyMVarMasked" $ \x f ->
monadicIOSim_ $ prop_modifyMVarMasked x f
]
]
]
import Test.QuickCheck
import Test.QuickCheck.Monadic (PropertyM, monitor, run)

{-------------------------------------------------------------------------------
Utilities
Expand Down
3 changes: 2 additions & 1 deletion io-sim/io-sim.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ test-suite test
hs-source-dirs: test
main-is: Main.hs
other-modules: Test.Control.Concurrent.Class.MonadMVar
Test.Control.Concurrent.Class.MonadMVar.Strict
Test.Control.Monad.STM
Test.Control.Monad.Utils
Test.Control.Monad.IOSim
Expand All @@ -108,7 +109,7 @@ test-suite test
build-depends: base,
array,
containers,
io-classes:{io-classes,strict-stm,si-timers},
io-classes:{io-classes,strict-stm,si-timers,testlib},
io-sim,
QuickCheck,
tasty,
Expand Down
2 changes: 2 additions & 0 deletions io-sim/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Main (main) where
import Test.Tasty

import Test.Control.Concurrent.Class.MonadMVar qualified (tests)
import Test.Control.Concurrent.Class.MonadMVar.Strict qualified (tests)
import Test.Control.Monad.IOSim qualified (tests)
import Test.Control.Monad.IOSimPOR qualified (tests)

Expand All @@ -13,6 +14,7 @@ tests :: TestTree
tests =
testGroup "io-sim-tests"
[ Test.Control.Concurrent.Class.MonadMVar.tests
, Test.Control.Concurrent.Class.MonadMVar.Strict.tests
, Test.Control.Monad.IOSim.tests
, Test.Control.Monad.IOSimPOR.tests
]
31 changes: 31 additions & 0 deletions io-sim/test/Test/Control/Concurrent/Class/MonadMVar/Strict.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Test.Control.Concurrent.Class.MonadMVar.Strict where

import Control.Monad.IOSim
import Test.Control.Concurrent.Class.MonadMVar.Strict.WHNF

import Test.Tasty
import Test.Tasty.QuickCheck

tests :: TestTree
tests = testGroup "Test.Control.Concurrent.Class.MonadMVar.Strict"
[ testGroup "WHNF"
[ testGroup "IOSIM"
[ testProperty "prop_newMVar" $ \x f ->
monadicIOSim_ $ prop_newMVar x f
, testProperty "prop_putMVar" $ \x f ->
monadicIOSim_ $ prop_putMVar x f
, testProperty "prop_swapMVar" $ \x f ->
monadicIOSim_ $ prop_swapMVar x f
, testProperty "prop_tryPutMVar" $ \x f ->
monadicIOSim_ $ prop_tryPutMVar x f
, testProperty "prop_modifyMVar_" $ \x f ->
monadicIOSim_ $ prop_modifyMVar_ x f
, testProperty "prop_modifyMVar" $ \x f ->
monadicIOSim_ $ prop_modifyMVar x f
, testProperty "prop_modifyMVarMasked_" $ \x f ->
monadicIOSim_ $ prop_modifyMVarMasked_ x f
, testProperty "prop_modifyMVarMasked" $ \x f ->
monadicIOSim_ $ prop_modifyMVarMasked x f
]
]
]
46 changes: 0 additions & 46 deletions test-strict-mvar/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit cb39dbc

Please sign in to comment.