Skip to content

Commit

Permalink
Made the validity tests compatible with all ghc versions that path su…
Browse files Browse the repository at this point in the history
…pports

Fixes #80.
  • Loading branch information
NorfairKing authored and sjakobi committed Mar 18, 2017
1 parent 44bdb34 commit 9cb4971
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
5 changes: 5 additions & 0 deletions lts-2.yaml
@@ -1 +1,6 @@
extra-deps:
- genvalidity-0.3.2.0
- genvalidity-property-0.0.0.0
- validity-0.3.3.0
resolver: lts-2.22

4 changes: 4 additions & 0 deletions lts-6.yaml
@@ -1 +1,5 @@
extra-deps:
- genvalidity-0.3.2.0
- genvalidity-property-0.0.0.0
- validity-0.3.3.0
resolver: lts-6.30
14 changes: 3 additions & 11 deletions path.cabal
Expand Up @@ -12,11 +12,6 @@ build-type: Simple
cabal-version: >=1.10
extra-source-files: README.md, CHANGELOG

flag validity
manual: True
default: False
description: Enable validity tests.

library
hs-source-dirs: src
ghc-options: -Wall -O2
Expand Down Expand Up @@ -46,20 +41,17 @@ test-suite test
default-language: Haskell2010

test-suite validity-test
if !flag(validity)
buildable: False
type: exitcode-stdio-1.0
main-is: ValidityTest.hs
other-modules: Path.Gen
hs-source-dirs: test
if flag(validity)
build-depends: QuickCheck
build-depends: QuickCheck
, aeson
, base >= 4.9 && < 5
, base >= 4.7 && < 5
, bytestring
, filepath < 1.2.0.1 || >= 1.3
, genvalidity >= 0.3 && < 0.4
, genvalidity-hspec >= 0.3 && < 0.4
, genvalidity-property >= 0.0 && < 0.1
, hspec >= 2.0 && < 3
, mtl >= 2.0 && < 3
, path
Expand Down
9 changes: 3 additions & 6 deletions stack.yaml
@@ -1,8 +1,5 @@
flags:
path:
validity: true
extra-deps:
- genvalidity-0.3.1.0
- genvalidity-hspec-0.3.1.0
- validity-0.3.2.0
- genvalidity-0.3.2.0
- genvalidity-property-0.0.0.0
- validity-0.3.3.0
resolver: lts-8.3
3 changes: 3 additions & 0 deletions test/Path/Gen.hs
@@ -1,6 +1,9 @@
{-# LANGUAGE FlexibleInstances #-}
module Path.Gen where

import Data.Functor
import Prelude

import Path
import Path.Internal

Expand Down
27 changes: 13 additions & 14 deletions test/ValidityTest.hs
@@ -1,4 +1,3 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand All @@ -15,7 +14,7 @@ import Path
import Path.Internal
import Test.Hspec
import Test.QuickCheck
import Test.Validity
import Test.Validity.Property

import Path.Gen

Expand Down Expand Up @@ -50,19 +49,19 @@ operationFilename = do
filename (parent </> file) `shouldBe` filename file

it "produces a valid path on when passed a valid absolute path" $ do
producesValidsOnValids (filename @Abs)
producesValidsOnValids (filename :: Path Abs File -> Path Rel File)

it "produces a valid path on when passed a valid relative path" $ do
producesValidsOnValids (filename @Rel)
producesValidsOnValids (filename :: Path Rel File -> Path Rel File)

-- | The 'parent' operation.
operationParent :: Spec
operationParent = do
it "produces a valid path on when passed a valid file path" $ do
producesValidsOnValids (parent @File)
producesValidsOnValids (parent :: Path Abs File -> Path Abs Dir)

it "produces a valid path on when passed a valid directory path" $ do
producesValidsOnValids (parent @Dir)
producesValidsOnValids (parent :: Path Abs Dir -> Path Abs Dir)

-- | The 'isParentOf' operation.
operationIsParentOf :: Spec
Expand Down Expand Up @@ -111,31 +110,31 @@ operationStripDir = do
stripDir parent (parent </> child) == Just child

it "produces a valid path on when passed a valid absolute file paths" $ do
producesValidsOnValids2 (stripDir @Maybe @Abs @File)
producesValidsOnValids2 (stripDir :: Path Abs Dir -> Path Abs File -> Maybe (Path Rel File))

it "produces a valid path on when passed a valid absolute directory paths" $ do
producesValidsOnValids2 (stripDir @Maybe @Abs @Dir)
producesValidsOnValids2 (stripDir :: Path Abs Dir -> Path Abs Dir -> Maybe (Path Rel Dir))

it "produces a valid path on when passed a valid relative file paths" $ do
producesValidsOnValids2 (stripDir @Maybe @Rel @File)
producesValidsOnValids2 (stripDir :: Path Rel Dir -> Path Rel File-> Maybe (Path Rel File))

it "produces a valid path on when passed a valid relative directory paths" $ do
producesValidsOnValids2 (stripDir @Maybe @Rel @Dir)
producesValidsOnValids2 (stripDir :: Path Rel Dir -> Path Rel Dir -> Maybe (Path Rel Dir))

-- | The '</>' operation.
operationAppend :: Spec
operationAppend = do
it "produces a valid path on when creating valid absolute file paths" $ do
producesValidsOnValids2 ((</>) @Abs @File)
producesValidsOnValids2 ((</>) :: Path Abs Dir -> Path Rel File -> Path Abs File)

it "produces a valid path on when creating valid absolute directory paths" $ do
producesValidsOnValids2 ((</>) @Abs @Dir)
producesValidsOnValids2 ((</>) :: Path Abs Dir -> Path Rel Dir -> Path Abs Dir)

it "produces a valid path on when creating valid relative file paths" $ do
producesValidsOnValids2 ((</>) @Rel @File)
producesValidsOnValids2 ((</>) :: Path Rel Dir -> Path Rel File -> Path Rel File)

it "produces a valid path on when creating valid relative directory paths" $ do
producesValidsOnValids2 ((</>) @Rel @Dir)
producesValidsOnValids2 ((</>) :: Path Rel Dir -> Path Rel Dir -> Path Rel Dir)

parserSpec :: (Show p, Validity p) => (FilePath -> Maybe p) -> Spec
parserSpec parser =
Expand Down

0 comments on commit 9cb4971

Please sign in to comment.