Skip to content

Commit

Permalink
Make 'genInfinite' generate truly infinite streams
Browse files Browse the repository at this point in the history
This makes the `prop_regression_shrinkAllNullErrors` property succeed, and not
loop forever during shrinking.
  • Loading branch information
jorisdral committed Dec 9, 2024
1 parent 4b8b851 commit dbc9f07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs-sim/src/System/FS/Sim/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ genFinite n gen = Stream Finite <$> replicateM n gen
genInfinite ::
Gen (Maybe a) -- ^ Tip: use 'genMaybe'.
-> Gen (Stream a)
genInfinite gen = Stream Infinite <$> QC.listOf gen
genInfinite gen = Stream Infinite <$> QC.infiniteListOf gen
11 changes: 9 additions & 2 deletions fs-sim/test/Test/System/FS/Sim/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ prop_regression_shrinkNotAllNullErrors :: Errors -> Property
prop_regression_shrinkNotAllNullErrors errs = expectFailure $
not (allNull errs) ==> property False

prop_regression_shrinkAllNullErrors :: Errors -> Property
prop_regression_shrinkAllNullErrors errs = expectFailure $
newtype AllNullErrors = AllNullErrors Errors
deriving Show

instance Arbitrary AllNullErrors where
arbitrary = AllNullErrors <$> oneof [ pure emptyErrors ]
shrink (AllNullErrors errs) = AllNullErrors <$> shrink errs

prop_regression_shrinkAllNullErrors :: AllNullErrors -> Property
prop_regression_shrinkAllNullErrors (AllNullErrors errs) = expectFailure $
allNull errs ==> property False

0 comments on commit dbc9f07

Please sign in to comment.