Skip to content

Commit 90592e7

Browse files
Revise shared test value types. (#237)
2 parents 08a2c0c + 7e97b06 commit 90592e7

18 files changed

+293
-223
lines changed

components/monoidmap-test/Data/MonoidMap/AccessSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ import Data.MonoidMap
2121
import Data.Proxy
2222
( Proxy (..) )
2323
import Test.Common
24-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
24+
( Key
25+
, Test
26+
, TestValueType (TestValueType)
27+
, makeSpec
28+
, property
29+
, testValueTypesAll
30+
)
2531
import Test.Hspec
2632
( Spec, describe, it )
2733
import Test.QuickCheck
@@ -34,7 +40,8 @@ import qualified Data.Set as Set
3440
spec :: Spec
3541
spec = describe "Accessors" $ do
3642

37-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
43+
forM_ testValueTypesAll $
44+
\(TestValueType p) -> specFor (Proxy @Key) p
3845

3946
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
4047
specFor = makeSpec $ do

components/monoidmap-test/Data/MonoidMap/ComparisonSpec.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ import Data.Proxy
2929
import Test.Common
3030
( Key
3131
, Test
32-
, TestType (TestType)
32+
, TestValueType (TestValueType)
3333
, makeSpec
3434
, property
35-
, testTypesGCDMonoid
36-
, testTypesMonoidNull
37-
, testTypesReductive
35+
, testValueTypesGCDMonoid
36+
, testValueTypesAll
37+
, testValueTypesReductive
3838
)
3939
import Test.Hspec
4040
( Spec, describe, it )
@@ -51,16 +51,16 @@ import qualified Data.Set as Set
5151
spec :: Spec
5252
spec = describe "Comparison" $ do
5353

54-
forM_ testTypesGCDMonoid $
55-
\(TestType p) -> specGCDMonoid
54+
forM_ testValueTypesGCDMonoid $
55+
\(TestValueType p) -> specGCDMonoid
5656
(Proxy @Key) p
5757

58-
forM_ testTypesReductive $
59-
\(TestType p) -> specReductive
58+
forM_ testValueTypesReductive $
59+
\(TestValueType p) -> specReductive
6060
(Proxy @Key) p
6161

62-
forM_ testTypesMonoidNull $
63-
\(TestType p) -> specMonoidNull
62+
forM_ testValueTypesAll $
63+
\(TestValueType p) -> specMonoidNull
6464
(Proxy @Key) p
6565

6666
specGCDMonoid

components/monoidmap-test/Data/MonoidMap/ConversionSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ import Data.Proxy
2525
import Data.Set
2626
( Set )
2727
import Test.Common
28-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
28+
( Key
29+
, Test
30+
, TestValueType (TestValueType)
31+
, makeSpec
32+
, property
33+
, testValueTypesAll
34+
)
2935
import Test.Hspec
3036
( Spec, describe, it )
3137
import Test.QuickCheck
@@ -42,7 +48,8 @@ import qualified Data.Set as Set
4248
spec :: Spec
4349
spec = describe "Conversions" $ do
4450

45-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
51+
forM_ testValueTypesAll $
52+
\(TestValueType p) -> specFor (Proxy @Key) p
4653

4754
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
4855
specFor = makeSpec $ do

components/monoidmap-test/Data/MonoidMap/DistributivitySpec.hs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ import Data.Proxy
2828
import Test.Common
2929
( Key
3030
, Test
31-
, TestType (..)
31+
, TestValueType (..)
3232
, TestValue
3333
, property
34-
, testTypesGCDMonoid
35-
, testTypesGroup
36-
, testTypesLCMMonoid
37-
, testTypesLeftGCDMonoid
38-
, testTypesLeftReductive
39-
, testTypesMonoidNull
40-
, testTypesMonus
41-
, testTypesOverlappingGCDMonoid
42-
, testTypesReductive
43-
, testTypesRightGCDMonoid
44-
, testTypesRightReductive
34+
, testValueTypesGCDMonoid
35+
, testValueTypesGroup
36+
, testValueTypesLCMMonoid
37+
, testValueTypesLeftGCDMonoid
38+
, testValueTypesLeftReductive
39+
, testValueTypesAll
40+
, testValueTypesMonus
41+
, testValueTypesOverlappingGCDMonoid
42+
, testValueTypesReductive
43+
, testValueTypesRightGCDMonoid
44+
, testValueTypesRightReductive
4545
)
4646
import Test.Hspec
4747
( Spec, describe, it )
@@ -79,95 +79,95 @@ spec = do
7979
specDistributiveGet :: Spec
8080
specDistributiveGet = do
8181
specForAll
82-
testTypesMonoidNull
82+
testValueTypesAll
8383
"Semigroup.<>"
8484
(Semigroup.<>)
8585
(Semigroup.<>)
8686
specForAll
87-
testTypesLeftGCDMonoid
87+
testValueTypesLeftGCDMonoid
8888
"LeftGCDMonoid.commonPrefix"
8989
(LeftGCDMonoid.commonPrefix)
9090
(LeftGCDMonoid.commonPrefix)
9191
specForAll
92-
testTypesRightGCDMonoid
92+
testValueTypesRightGCDMonoid
9393
"RightGCDMonoid.commonSuffix"
9494
(RightGCDMonoid.commonSuffix)
9595
(RightGCDMonoid.commonSuffix)
9696
specForAll
97-
testTypesOverlappingGCDMonoid
97+
testValueTypesOverlappingGCDMonoid
9898
"OverlappingGCDMonoid.overlap"
9999
(OverlappingGCDMonoid.overlap)
100100
(OverlappingGCDMonoid.overlap)
101101
specForAll
102-
testTypesGCDMonoid
102+
testValueTypesGCDMonoid
103103
"GCDMonoid.gcd"
104104
(GCDMonoid.gcd)
105105
(GCDMonoid.gcd)
106106
specForAll
107-
testTypesLCMMonoid
107+
testValueTypesLCMMonoid
108108
"LCMMonoid.lcm"
109109
(LCMMonoid.lcm)
110110
(LCMMonoid.lcm)
111111
specForAll
112-
testTypesGroup
112+
testValueTypesGroup
113113
"Group.minus"
114114
(Group.~~)
115115
(Group.~~)
116116
specForAll
117-
testTypesMonus
117+
testValueTypesMonus
118118
"Monus.monus"
119119
(Monus.<\>)
120120
(Monus.<\>)
121121
where
122122
specForAll
123-
:: [TestType c]
123+
:: [TestValueType c]
124124
-> String
125125
-> (forall k v m. (Test k v, c v, m ~ MonoidMap k v) => (m -> m -> m))
126126
-> (forall v. (TestValue v, c v) => (v -> v -> v))
127127
-> Spec
128-
specForAll testTypes funName f g =
129-
describe description $ forM_ testTypes $ specFor f g
128+
specForAll testValueTypes funName f g =
129+
describe description $ forM_ testValueTypes $ specFor f g
130130
where
131131
description = "Distributivity of 'get' with '" <> funName <> "'"
132132

133133
specFor
134134
:: (forall k v m. (Test k v, c v, m ~ MonoidMap k v) => (m -> m -> m))
135135
-> (forall v. (TestValue v, c v) => (v -> v -> v))
136-
-> TestType c
136+
-> TestValueType c
137137
-> Spec
138-
specFor f g (TestType (_ :: Proxy v)) =
138+
specFor f g (TestValueType (_ :: Proxy v)) =
139139
it description $ property $ propDistributiveGet @Key @v f g
140140
where
141141
description = show $ typeRep $ Proxy @(MonoidMap Key v)
142142

143143
specDistributiveGetMaybe :: Spec
144144
specDistributiveGetMaybe = do
145145
specForAll
146-
testTypesLeftReductive
146+
testValueTypesLeftReductive
147147
"LeftReductive.stripPrefix"
148148
(LeftReductive.stripPrefix)
149149
(LeftReductive.stripPrefix)
150150
specForAll
151-
testTypesRightReductive
151+
testValueTypesRightReductive
152152
"RightReductive.stripSuffix"
153153
(RightReductive.stripSuffix)
154154
(RightReductive.stripSuffix)
155155
specForAll
156-
testTypesReductive
156+
testValueTypesReductive
157157
"Reductive.minusMaybe"
158158
(Reductive.</>)
159159
(Reductive.</>)
160160
where
161161
specForAll
162-
:: [TestType c]
162+
:: [TestValueType c]
163163
-> String
164164
-> (forall k v m. (Test k v, c v, m ~ MonoidMap k v)
165165
=> (m -> m -> Maybe m))
166166
-> (forall v. (TestValue v, c v)
167167
=> (v -> v -> Maybe v))
168168
-> Spec
169-
specForAll testTypes funName f g =
170-
describe description $ forM_ testTypes $ specFor f g
169+
specForAll testValueTypes funName f g =
170+
describe description $ forM_ testValueTypes $ specFor f g
171171
where
172172
description = "Distributivity of 'get' with '" <> funName <> "'"
173173

@@ -176,9 +176,9 @@ specDistributiveGetMaybe = do
176176
=> (m -> m -> Maybe m))
177177
-> (forall v. (TestValue v, c v)
178178
=> (v -> v -> Maybe v))
179-
-> TestType c
179+
-> TestValueType c
180180
-> Spec
181-
specFor f g (TestType (_ :: Proxy v)) =
181+
specFor f g (TestValueType (_ :: Proxy v)) =
182182
it description $ property $ propDistributiveGetMaybe @Key @v f g
183183
where
184184
description = show $ typeRep $ Proxy @(MonoidMap Key v)

components/monoidmap-test/Data/MonoidMap/FilterSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ import Data.Proxy
2323
import GHC.Exts
2424
( IsList (..) )
2525
import Test.Common
26-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
26+
( Key
27+
, Test
28+
, TestValueType (TestValueType)
29+
, makeSpec
30+
, property
31+
, testValueTypesAll
32+
)
2733
import Test.Hspec
2834
( Spec, describe, it )
2935
import Test.QuickCheck
@@ -35,7 +41,8 @@ import qualified Data.MonoidMap as MonoidMap
3541
spec :: Spec
3642
spec = describe "Filtering" $ do
3743

38-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
44+
forM_ testValueTypesAll $
45+
\(TestValueType p) -> specFor (Proxy @Key) p
3946

4047
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
4148
specFor = makeSpec $ do

components/monoidmap-test/Data/MonoidMap/FoldSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ import Data.MonoidMap
1717
import Data.Proxy
1818
( Proxy (..) )
1919
import Test.Common
20-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
20+
( Key
21+
, Test
22+
, TestValueType (TestValueType)
23+
, makeSpec
24+
, property
25+
, testValueTypesAll
26+
)
2127
import Test.Hspec
2228
( Spec, describe, it )
2329
import Test.QuickCheck
@@ -29,7 +35,8 @@ import qualified Data.MonoidMap as MonoidMap
2935
spec :: Spec
3036
spec = describe "Folding" $ do
3137

32-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
38+
forM_ testValueTypesAll $
39+
\(TestValueType p) -> specFor (Proxy @Key) p
3340

3441
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
3542
specFor = makeSpec $ do

components/monoidmap-test/Data/MonoidMap/IntersectionSpec.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import Data.Proxy
2727
import Test.Common
2828
( Key
2929
, Test
30-
, TestType (TestType)
30+
, TestValueType (TestValueType)
3131
, makeSpec
3232
, property
33-
, testTypesGCDMonoid
34-
, testTypesMonoidNull
33+
, testValueTypesGCDMonoid
34+
, testValueTypesAll
3535
)
3636
import Test.Hspec
3737
( Spec, describe, it )
@@ -45,11 +45,11 @@ import qualified Data.Set as Set
4545
spec :: Spec
4646
spec = describe "Intersection" $ do
4747

48-
forM_ testTypesMonoidNull $
49-
\(TestType p) -> specMonoidNull
48+
forM_ testValueTypesAll $
49+
\(TestValueType p) -> specMonoidNull
5050
(Proxy @Key) p
51-
forM_ testTypesGCDMonoid $
52-
\(TestType p) -> specGCDMonoid
51+
forM_ testValueTypesGCDMonoid $
52+
\(TestValueType p) -> specGCDMonoid
5353
(Proxy @Key) p
5454

5555
specMonoidNull :: forall k v. Test k v => Proxy k -> Proxy v -> Spec

components/monoidmap-test/Data/MonoidMap/MapSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ import Data.MonoidMap
2525
import Data.Proxy
2626
( Proxy (..) )
2727
import Test.Common
28-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
28+
( Key
29+
, Test
30+
, TestValueType (TestValueType)
31+
, makeSpec
32+
, property
33+
, testValueTypesAll
34+
)
2935
import Test.Hspec
3036
( Spec, describe, it )
3137
import Test.QuickCheck
@@ -39,7 +45,8 @@ import qualified Data.Set as Set
3945
spec :: Spec
4046
spec = describe "Mapping" $ do
4147

42-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
48+
forM_ testValueTypesAll $
49+
\(TestValueType p) -> specFor (Proxy @Key) p
4350

4451
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
4552
specFor = makeSpec $ do

components/monoidmap-test/Data/MonoidMap/MembershipSpec.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ import Data.MonoidMap
2121
import Data.Proxy
2222
( Proxy (..) )
2323
import Test.Common
24-
( Key, Test, TestType (TestType), makeSpec, property, testTypesMonoidNull )
24+
( Key
25+
, Test
26+
, TestValueType (TestValueType)
27+
, makeSpec
28+
, property
29+
, testValueTypesAll
30+
)
2531
import Test.Hspec
2632
( Spec, describe, it )
2733
import Test.QuickCheck
@@ -33,7 +39,8 @@ import qualified Data.Set as Set
3339
spec :: Spec
3440
spec = describe "Membership" $ do
3541

36-
forM_ testTypesMonoidNull $ \(TestType p) -> specFor (Proxy @Key) p
42+
forM_ testValueTypesAll $
43+
\(TestValueType p) -> specFor (Proxy @Key) p
3744

3845
specFor :: forall k v. Test k v => Proxy k -> Proxy v -> Spec
3946
specFor = makeSpec $ do

0 commit comments

Comments
 (0)