Skip to content

Commit e8c2547

Browse files
committed
add tests
1 parent c67c365 commit e8c2547

15 files changed

+351
-3
lines changed

Cabal/Cabal.cabal

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ extra-source-files:
7373
tests/ParserTests/errors/spdx-2.errors
7474
tests/ParserTests/errors/spdx-3.cabal
7575
tests/ParserTests/errors/spdx-3.errors
76+
tests/ParserTests/errors/version-sets-1.cabal
77+
tests/ParserTests/errors/version-sets-1.errors
78+
tests/ParserTests/errors/version-sets-2.cabal
79+
tests/ParserTests/errors/version-sets-2.errors
80+
tests/ParserTests/errors/version-sets-3.cabal
81+
tests/ParserTests/errors/version-sets-3.errors
82+
tests/ParserTests/errors/version-sets-4.cabal
83+
tests/ParserTests/errors/version-sets-4.errors
7684
tests/ParserTests/ipi/Includes2.cabal
7785
tests/ParserTests/ipi/Includes2.expr
7886
tests/ParserTests/ipi/Includes2.format
@@ -172,6 +180,9 @@ extra-source-files:
172180
tests/ParserTests/regressions/th-lift-instances.cabal
173181
tests/ParserTests/regressions/th-lift-instances.expr
174182
tests/ParserTests/regressions/th-lift-instances.format
183+
tests/ParserTests/regressions/version-sets.cabal
184+
tests/ParserTests/regressions/version-sets.expr
185+
tests/ParserTests/regressions/version-sets.format
175186
tests/ParserTests/regressions/wl-pprint-indef.cabal
176187
tests/ParserTests/regressions/wl-pprint-indef.expr
177188
tests/ParserTests/regressions/wl-pprint-indef.format

Cabal/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 2.6.0.0 (current development version)
22
* TODO
3-
* `^>=` takes multiple parameters
3+
* Introduce set notation for `^>=` and `==` operators.
44
* 'check' reports warnings for various ghc-\*-options fields separately
55
([#5342](https://github.com/haskell/cabal/issues/5432)).
66
* `KnownExtension`: added new extension `DerivingVia`.

Cabal/Distribution/Types/VersionRange.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,15 @@ instance Parsec VersionRange where
495495
verSet :: CabalParsing m => m [Version]
496496
verSet = do
497497
_ <- P.char '{'
498-
vs <- P.sepBy1 (P.spaces *> verPlain) (P.try (P.spaces *> P.char ','))
499498
P.spaces
499+
vs <- P.sepBy1 (verPlain <* P.spaces) (P.char ',' *> P.spaces)
500500
_ <- P.char '}'
501501
pure vs
502502

503-
-- plain version without tags or wildcards
503+
-- a plain version without tags or wildcards
504+
-- note: this uses P.integral which allows redundant zeros.
505+
-- This is not a problem because 'verPlain' is only used by
506+
-- 'verSet' which requires cabal > 3
504507
verPlain :: CabalParsing m => m Version
505508
verPlain = mkVersion <$> P.sepBy1 P.integral (P.char '.')
506509

Cabal/tests/ParserTests.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ errorTests = testGroup "errors"
112112
, errorTest "spdx-2.cabal"
113113
, errorTest "spdx-3.cabal"
114114
, errorTest "removed-fields.cabal"
115+
, errorTest "version-sets-1.cabal"
116+
, errorTest "version-sets-2.cabal"
117+
, errorTest "version-sets-3.cabal"
118+
, errorTest "version-sets-4.cabal"
115119
]
116120

117121
errorTest :: FilePath -> TestTree
@@ -159,6 +163,7 @@ regressionTests = testGroup "regressions"
159163
, regressionTest "spdx-3.cabal"
160164
, regressionTest "hidden-main-lib.cabal"
161165
, regressionTest "jaeger-flamegraph.cabal"
166+
, regressionTest "version-sets.cabal"
162167
]
163168

164169
regressionTest :: FilePath -> TestTree
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cabal-version: 2.5
2+
name: version-sets
3+
version: 0
4+
synopsis: version set notation
5+
6+
library
7+
default-language: Haskell2010
8+
build-depends: network == { }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION: Just (mkVersion [2,5])
2+
version-sets-1.cabal:8:31:
3+
unexpected "}"
4+
expecting space or integral
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cabal-version: 2.5
2+
name: version-sets
3+
version: 0
4+
synopsis: version set notation
5+
6+
library
7+
default-language: Haskell2010
8+
build-depends: network >= { 2.8.0.0 }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION: Just (mkVersion [2,5])
2+
version-sets-2.cabal:8:29:
3+
unexpected "{"
4+
expecting space or integral
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cabal-version: 2.5
2+
name: version-sets
3+
version: 0
4+
synopsis: version set notation
5+
6+
library
7+
default-language: Haskell2010
8+
build-depends: network == { 2.8.0.0, }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION: Just (mkVersion [2,5])
2+
version-sets-3.cabal:8:40:
3+
unexpected "}"
4+
expecting space or integral
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cabal-version: 2.5
2+
name: version-sets
3+
version: 0
4+
synopsis: version set notation
5+
6+
library
7+
default-language: Haskell2010
8+
build-depends: network == { 2.8.* }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION: Just (mkVersion [2,5])
2+
version-sets-4.cabal:8:35:
3+
unexpected "*"
4+
expecting integral
5+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cabal-version: 2.5
2+
name: version-sets
3+
version: 0
4+
synopsis: version set notation
5+
tested-with: GHC == { 8.6.3, 8.4.4, 8.2.2, 8.0.2, 7.10.3, 7.8.4, 7.6.3, 7.4.2 }
6+
7+
library
8+
default-language: Haskell2010
9+
build-depends: network ^>= {0}
10+
build-depends: base == {1}, base == { 1 }, base == {1,2}, base == {1.2}, base == {1.2,3.4}
11+
build-depends: ghc == {
12+
8.6.3
13+
,
14+
8.4.4 ,8.2.2 ,
15+
8.0.2,7.10.3
16+
, 7.8.4, 7.6.3, 7.4.2
17+
}
18+
build-depends: Cabal ^>= { 2.4.1.1, 2.2.0.0 }

0 commit comments

Comments
 (0)