1

I am writing a simple test using quickcheck.

import Test.QuickCheck

f :: Int -> Int 
f x
        | x < 0 = (-x)
        | otherwise = x 

main = do
        putStrLn "Testing"
        quickCheck ((\x -> ((f x) >= 0)) :: Int -> Bool)

Whenever I run this via $ runhaskell test.hs, I see one of 2 different results. Either I get: Testing +++ OK, passed 100 tests. Or: I get no output, and the program terminates. I cannot reason about this behavior.

This is on Quickcheck 2.5.1.1, and ghc 7.4.2.

rsinha
  • 2,167
  • 3
  • 18
  • 17
  • You don't need the
     tags; [Markdown](http://stackoverflow.com/editing-help) doesn't recognize those language declarations anyway.  Just indent your code four spaces, using the `{}` button above the code editor window.
    – Robert Harvey Nov 19 '12 at 03:30
  • ah, thanks! Havent used StackOverflow in a while. – rsinha Nov 19 '12 at 03:38
  • Can't reproduce with ghc 7.4.1 and quickcheck 2.5 – Norman Ramsey Nov 19 '12 at 04:02
  • Do you change the property so that quickcheck should fail, and then you get no output (eg change `>=` to `<`), or is it the same code that randomly switches between passing the tests, and giving no output? – Boris Nov 19 '12 at 13:27
  • Does it also switch between printing and not printing a) in GHCi, b) when you run compiled code? – Daniel Fischer Nov 19 '12 at 14:05
  • @Boris, yes I tried that. I still get the switching between printing and not printing. – rsinha Nov 19 '12 at 17:35
  • @DanielFischer yes it works fine in GHCi and compiled code. (btw GHCi segfaulted once at start time, that is before loading the prompt) – rsinha Nov 19 '12 at 17:45
  • Then it would seem that `runhaskell` is somehow causing it. But GHCi segfaulting seems odd. Any information on why? – Daniel Fischer Nov 19 '12 at 18:23
  • 1
    It might be worth trying to run `runhaskell test.hs; echo $?`. This will give you the exit code of runhaskell. If it is non-zero, this indicates an error; if it is greater than 127, it indicates that runhaskell was killed by a signal. – Lars Noschinski Dec 06 '12 at 09:21

0 Answers0