Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version bound for QuickCheck 2.13 #410

Closed
nick8325 opened this issue Mar 26, 2019 · 13 comments
Closed

Bump version bound for QuickCheck 2.13 #410

nick8325 opened this issue Mar 26, 2019 · 13 comments

Comments

@nick8325
Copy link
Contributor

I just released QuickCheck 2.13. There are no major API changes and Hspec at least builds with it (I haven't run it) but at least the version bounds will need relaxing.

It also uses splitmix rather than tf-random for random number generation, which perhaps makes #406 obsolete.

@sol
Copy link
Member

sol commented Mar 27, 2019

@nick8325 there seems to be something fishy.

Given

ghci> import Test.QuickCheck
ghci> import Test.QuickCheck.Random 
ghci> let p = (/= 1) :: Int -> Bool
ghci> let qc = quickCheckWith stdArgs {replay = Just (mkQCGen 0, 0)}

I observe that verbose changes the number of tests that are run:

ghci> qc p
*** Failed! Falsified (after 6 tests):                      
1

vs

ghci> qc (verbose p)
...
...
...
*** Failed! Falsified (after 3 tests):                      
1

Is this expected?

@nick8325
Copy link
Contributor Author

nick8325 commented Mar 28, 2019

This is really strange. I hadn't thought about making verbose p and p behave identically (only that they should have the same distribution of test cases), but of course they should if at all possible.

The weird thing is that this works with TFGen, but not with SMGen or StdGen! Just changing Test.QuickCheck.Random so that it calls newStdGen and mkStdGen instead of newTFGen and mkTFGen causes your example to break. So it seems that TFGen is doing something very strange here. I'll have to look into it more closely.

@nick8325
Copy link
Contributor Author

Oops:

import Test.QuickCheck
import System.Random
import System.Random.TF

prop_rng :: Int -> Property
prop_rng n =
  expectFailure $
  genInt g === genInt (fst (split g))
  where
    genInt :: TFGen -> Int
    genInt g = fst (next g)

    g :: TFGen
    g = mkTFGen n

> quickCheck prop_rng 
*** Failed! Passed 100 tests (expected failure).

It looks like the problem only occurs with mkTFGen and not newTFGen.

@nick8325
Copy link
Contributor Author

My initial impression is that this bug shouldn't worsen testing, at least, because a seed in QuickCheck is either split or applied to next, never both in the same property.

@sol
Copy link
Member

sol commented Mar 28, 2019

@nick8325 there is more. Apparently failingTestCase means something different now. Consider:

ghci> let qc = quickCheckWithResult stdArgs {chatty = False, replay = Just (mkQCGen 0, 0)}

With 2.12.6.1:

> failingTestCase <$> qc ((==) :: Int -> Int -> Bool)
["0","1"]

vs 2.13

ghci> failingTestCase <$> qc ((==) :: Int -> Int -> Bool)
["1\n0"]

@sol
Copy link
Member

sol commented Mar 28, 2019

@snoyberg @alexeyzab I can't comment on commercialhaskell/stackage#4444. hspec compatibility with QuickChekc-1.13 will be blocked until we have sorted this stuff out.

@alexeyzab
Copy link

@sol 👍

@nick8325
Copy link
Contributor Author

@sol Both of those should be fixed now. Let me know if you're happy for me to make a new release.

@nick8325
Copy link
Contributor Author

Ah wait, not sure that it's working yet. I'll report back...

@nick8325
Copy link
Contributor Author

There, that should be actually fixed now.

@sol
Copy link
Member

sol commented Mar 29, 2019

@nick8325 looks good now. Let me know once it's on Hackage._

@nick8325
Copy link
Contributor Author

There, 2.13.1 is now on Hackage!

@sol
Copy link
Member

sol commented Mar 29, 2019

On Hackage, closing.

@sol sol closed this as completed Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants