Skip to content

Commit 3ea5525

Browse files
nikita-volkovgithub-actions[bot]
authored andcommitted
Format
1 parent d2d9bc6 commit 3ea5525

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

stm-containers.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ test-suite test
132132
main-is: Main.hs
133133
other-modules:
134134
Suites.Bimap
135-
Suites.Set
136135
Suites.Map
137136
Suites.Map.Update
137+
Suites.Set
138138

139139
build-depends:
140140
deferred-folds,

test/Suites/Set.hs

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
module Suites.Set (tests) where
22

3+
import Control.Concurrent.STM
34
import qualified Control.Foldl as Foldl
5+
import Control.Monad (forM_)
46
import Control.Monad.Free
7+
import Data.Hashable
8+
import Data.List (nub, sort, splitAt)
9+
import Data.Word (Word8)
510
import qualified DeferredFolds.UnfoldlM as UnfoldlM
611
import qualified Focus
7-
import qualified StmContainers.Set as StmSet
812
import qualified ListT
13+
import qualified StmContainers.Set as StmSet
14+
import System.IO.Unsafe (unsafePerformIO)
915
import Test.QuickCheck.Instances ()
1016
import Test.Tasty
1117
import Test.Tasty.HUnit
1218
import Test.Tasty.QuickCheck
13-
import Prelude hiding (null, choose)
14-
import System.IO.Unsafe (unsafePerformIO)
15-
import Control.Monad (forM_)
16-
import Control.Concurrent.STM
17-
import Data.Hashable
18-
import Data.List (nub, sort, splitAt)
19-
import Data.Word (Word8)
19+
import Prelude hiding (choose, null)
2020

2121
-- helpers
2222

@@ -47,20 +47,22 @@ instance Hashable TestKey where
4747

4848
tests :: [TestTree]
4949
tests =
50-
[ testProperty "sizeAndList" $
51-
let gen = nub <$> listOf (choose ('a', 'z'))
52-
prop xs =
53-
length xs == stmSetSize
54-
where
55-
stmSetSize =
56-
unsafePerformIO $ atomically $ do
57-
s <- stmSetFromList xs
58-
StmSet.size s
59-
in forAll gen prop,
50+
[ testProperty "sizeAndList"
51+
$ let gen = nub <$> listOf (choose ('a', 'z'))
52+
prop xs =
53+
length xs == stmSetSize
54+
where
55+
stmSetSize =
56+
unsafePerformIO $ atomically $ do
57+
s <- stmSetFromList xs
58+
StmSet.size s
59+
in forAll gen prop,
6060
testProperty "fromListToListSetIsomorphism" $ \(xs :: [Int]) ->
6161
let setList =
62-
unsafePerformIO $ atomically $
63-
stmSetFromList xs >>= stmSetToList
62+
unsafePerformIO
63+
$ atomically
64+
$ stmSetFromList xs
65+
>>= stmSetToList
6466
in sort (nub xs) === sort setList,
6567
testProperty "listTNonAtomicIsomorphism" $ \(xs :: [Int]) ->
6668
let setList =
@@ -82,25 +84,28 @@ tests =
8284
return (sz, sort ls)
8385
expected =
8486
let remaining = nub (filter (`notElem` dropped) ks)
85-
in (length remaining, sort remaining)
87+
in (length remaining, sort remaining)
8688
in (finalSize, finalList) === expected,
87-
testCase "insert" $
88-
assertEqual "" (sort ['a','b','c']) =<< do
89+
testCase "insert"
90+
$ assertEqual "" (sort ['a', 'b', 'c'])
91+
=<< do
8992
atomically $ do
9093
s <- StmSet.new
9194
StmSet.insert 'a' s
9295
StmSet.insert 'c' s
9396
StmSet.insert 'b' s
9497
sort <$> stmSetToList s,
95-
testCase "focusInsert" $
96-
assertEqual "" (sort ['a','b']) =<< do
98+
testCase "focusInsert"
99+
$ assertEqual "" (sort ['a', 'b'])
100+
=<< do
97101
atomically $ do
98102
s <- StmSet.new
99103
StmSet.focus (Focus.insert ()) 'a' s
100104
StmSet.focus (Focus.insert ()) 'b' s
101105
sort <$> stmSetToList s,
102-
testCase "insertAndDelete" $
103-
assertEqual "" ['b'] =<< do
106+
testCase "insertAndDelete"
107+
$ assertEqual "" ['b']
108+
=<< do
104109
atomically $ do
105110
s <- StmSet.new
106111
StmSet.focus (Focus.insert ()) 'a' s
@@ -110,8 +115,9 @@ tests =
110115
testCase "nullAndNotNull" $ do
111116
assertEqual "" True =<< atomically (StmSet.null =<< StmSet.new)
112117
assertEqual "" False =<< atomically (StmSet.null =<< stmSetFromList ['a']),
113-
testCase "nullAfterDeletingTheLastElement" $
114-
assertEqual "" True =<< do
118+
testCase "nullAfterDeletingTheLastElement"
119+
$ assertEqual "" True
120+
=<< do
115121
atomically $ do
116122
s <- stmSetFromList ['a']
117123
StmSet.delete 'a' s

0 commit comments

Comments
 (0)