[QuickCheck] uncaught exception: SomeAsyncException (stack overflow) (after 3 tests and 3 shrinks)

Nick Smallbone nicsma at chalmers.se
Sun Apr 17 14:43:13 BST 2016


Hi Boris,

The uncaught exception is because your function crashes for negative
numbers. Try multBy (-1) 0 in GHCi and you will get the same result.

Nick

On Saturday 16 April, 2016 at 04:02 pm, Boris Rozinov wrote:
> 
> multBy:: (Eq a, Integral a) => a -> a -> a
> multBy 0 _ = 0
> multBy 1 n = n
> multBy m n = n+ multBy (m-1) n
> 
> multByI::Integer->Integer->Integer 
> multByI i1 i2= i1*i2
> 
> --works fine:
>        it "x*y(i)  is always eq to y*x" $ do
>             property $ (\x y -> (multByI x y) == (multByI y x::Integer) )
> 
> 
> --but this one gives error:
>         it "x*y  is always eq to y*x" $ do
>             property $ (\x y -> (multBy (x::Integer) (y::Integer)) == (multBy (y::Integer) (x::Integer)) )
> 
> 
>   Addition.hs:32:
>   1) Addition x*y  is always eq to y*x
>        uncaught exception: SomeAsyncException (stack overflow) (after 3 tests and 3 shrinks)
>        0
>        -1
> 
> Randomized with seed 1748887214
> 
> Finished in 92.4021 seconds
> 12 examples, 1 failure
> *** Exception: ExitFailure 1
> 
> Thanks, Boris
> 
> 

> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck




More information about the QuickCheck mailing list