zudov / purescript-strongcheck-generics

Generics for purescript-strongcheck
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

Issues while updating to 0.10.2 #5

Open sectore opened 7 years ago

sectore commented 7 years ago

Hi Konstantin, to use purescript-strongcheck-generics with latest 0.10.2 I've updated few dependencies the package and added tiny changes to the code with the following commit: https://github.com/sectore/purescript-strongcheck-generics/commit/af7edf02e95ede30998c8d3df33f517f4995d954

psci is happy about all changes. However, it seems that the recursion of the Tree a example causes some issues while running the tests. The tests runs only if I disable all checks of Tree Int (see commit mentioned above).

Running the tests of props_gArbitrary without showSample / quickCheck using Tree Int

* Running tests...
100/100 test(s) passed.
1/1 test(s) passed.
[Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)),Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)),Test.Main.Nil,Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)))))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))]
* Tests OK.

Running the tests of props_gArbitrary with showSample / quickCheck by using Tree Int. Tests are "holded" as follows:

* Running tests...
100/100 test(s) passed.
1/1 test(s) passed.
[Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)),Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons Test.Main.Nil),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)),Test.Main.Nil,Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil)))))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))))),Test.Main.Cons (Test.Main.Cons (Test.Main.Cons Test.Main.Nil))]

It seems that the recursion of nested (Tree) data are failed. I dived into Test.StrongCheck.Generic.gArbitrary, also into Test.StrongCheck.Generic.genGenericSpine but I could not find out how to fix this issue.

Any idea?

Thanks!

-Jens

zudov commented 7 years ago

Hi, thanks for help, and sorry for late reply.

I looked at it now (your points helped) and it appears that the problem is somewhere deeper, in the derived toSignature. I opened an issue here https://github.com/purescript/purescript/issues/2482

BartAdv commented 7 years ago

Since the purescript/purescript#2482 is closed, what's the status of this one?

zudov commented 7 years ago

I gonna take another bite at this issue now.

themoritz commented 7 years ago

@zudov I've had a look at the code and the issue is the SigArray case in genGenericSpine' (and in particular arrayOf).

This becomes problematic when combining Array with recursive data structures (like your Tree example), because for every Branch between 0 and 10 subtrees are generated, where 10 is the default size arrayOf uses. So the recursion only stops in the case of 0, and with very high probability you get an exponentially growing tree, so the code doesn't terminate.

There are two possible solutions:

themoritz commented 7 years ago

Hm, my reasoning can't be correct since it actually worked with PureScript 0.9.3. :) However, I was able to make it work with 0.10.5 generating empty or singleton arrays with 0.5 probability.

Another reason might be that strongcheck is just "painfully" slow since psc 0.10: https://github.com/purescript-contrib/purescript-strongcheck/issues/38

garyb commented 7 years ago

I wondered about that too. An easy-ish test would be to use quickcheck instead of strongcheck and see if it's still misbehaving. I'm not sure, but I don't think this uses any strongcheck specific features.

And by "painfully" I meant something like 10x slower, it shouldn't be bad enough to make things run indefinitely as seems to happen now.

themoritz commented 7 years ago

Some observations after playing around with it:

So it seems to me there is some exponential runtime bug somewhere, but I can't tell where...

legrostdg commented 7 years ago

Any news on this issue? It is preventing purescript-argonaut-generic-codecs, purescript-bridge, purescript-servant-support from upgrading to 0.10.x

https://github.com/eskimor/purescript-argonaut-generic-codecs/pull/8 https://github.com/eskimor/purescript-bridge/issues/16 https://github.com/eskimor/purescript-servant-support/pull/4

themoritz commented 7 years ago

I would be in favor of skipping the Tree test for now, so that the tests can pass and a release can be made.

And maybe put a warning somewhere about the combination of recursive data types and arrays.