File tree Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ library
5151 base >= 4.12 && < 5
5252 , hnix-store-core >= 0.8
5353 , bytestring
54+ , containers
5455 , crypton
5556 , dependent-sum > 0.7
5657 , generic-arbitrary < 1.1
@@ -80,7 +81,5 @@ test-suite props
8081 , hnix-store-core
8182 , hnix-store-tests
8283 , attoparsec
83- , containers
84- , QuickCheck
8584 , text
8685 , hspec
Original file line number Diff line number Diff line change 33{-# OPTIONS_GHC -Wno-orphans #-}
44module System.Nix.Arbitrary.DerivedPath where
55
6- import Test.QuickCheck (Arbitrary )
6+ import qualified Data.Set
7+ import Test.QuickCheck (Arbitrary (.. ), oneof )
78import Test.QuickCheck.Arbitrary.Generic (GenericArbitrary (.. ))
89import System.Nix.Arbitrary.StorePath ()
9- import System.Nix.DerivedPath (DerivedPath , OutputsSpec )
10+ import System.Nix.DerivedPath (DerivedPath , OutputsSpec ( .. ) )
1011
11- deriving via GenericArbitrary OutputsSpec
12- instance Arbitrary OutputsSpec
12+ instance Arbitrary OutputsSpec where
13+ arbitrary = oneof
14+ [ pure OutputsSpec_All
15+ , OutputsSpec_Names
16+ . Data.Set. fromList
17+ <$> ((:) <$> arbitrary <*> arbitrary)
18+ ]
1319
1420deriving via GenericArbitrary DerivedPath
1521 instance Arbitrary DerivedPath
Original file line number Diff line number Diff line change 11module DerivedPathSpec where
22
3- import Test.Hspec (Spec , describe , shouldBe )
3+ import Test.Hspec (Spec , describe )
44import Test.Hspec.QuickCheck (prop )
5- import Test.QuickCheck ( Arbitrary ( arbitrary ), forAll , suchThat )
5+ import Test.Hspec.Nix ( roundtrips )
66
77import System.Nix.Arbitrary ()
8- import System.Nix.DerivedPath (DerivedPath (.. ), OutputsSpec (.. ))
98
10- import qualified Data.Set
119import qualified System.Nix.DerivedPath
1210
1311spec :: Spec
1412spec = do
1513 describe " DerivedPath" $ do
1614 prop " roundtrips" $ \ sd ->
17- forAll (arbitrary `suchThat` nonEmptyOutputsSpec_Names) $ \ p ->
18- System.Nix.DerivedPath. parseDerivedPath sd
19- (System.Nix.DerivedPath. derivedPathToText sd p)
20- `shouldBe` pure p
21- where
22- nonEmptyOutputsSpec_Names :: DerivedPath -> Bool
23- nonEmptyOutputsSpec_Names (DerivedPath_Built _ (OutputsSpec_Names set)) =
24- not $ Data.Set. null set
25- nonEmptyOutputsSpec_Names _ = True
15+ roundtrips
16+ (System.Nix.DerivedPath. derivedPathToText sd)
17+ (System.Nix.DerivedPath. parseDerivedPath sd)
You can’t perform that action at this time.
0 commit comments