[Haskell-cafe] HUnit false-positive stumper
quick at sparq.org
Wed Jun 8 03:34:25 CEST 2011
Didn't get to this last night but I've just now confirmed this. With a normal build (defaulting to -O) the test code below generates only 3 failures (MacOS Leopard w/GHC 6.12.3 and HUnit 22.214.171.124). When using -O0 or by changing assertFailure in Test.HUnit.Lang (line 81) to use E.throwIO instead of E.throw I get the expected 6 failures. This is very reproducible for me.
I can use -O0 for my tests, but it would be great if HUnit were updated to use the throwIO call (cc'ing Richard Giraud accordingly).
> module Main where
> import Control.Monad (unless)
> import Test.HUnit
> main = runTestTT $ TestList [ True ~=? True
> , False ~=? True
> , TestCase $ assertEqual "both true" True True
> , TestCase $ assertEqual "false true" False True
> , TestCase $ assertEqual "fa" False True
> , TestCase $ assertEqual "f" False True
> , TestCase $ (False @?= True)
> , TestCase $ unless (False == True) (assertFailure "f")
On Mon, 06 Jun 2011 09:00:07 -0700, <quick at sparq.org> wrote:
> That sounds very applicable to my issue (and unfortunately my googling missed
> this, ergo my consult of haskell-cafe uberwissenmensch). When I again have
> access to the aforementioned Mac this evening I'll try both disabling
> optimizations and a tweaked HUnit to see if that resolves the problem and
> report back then.
> Quoting Max Bolingbroke <batterseapower at hotmail.com>:
>> On 6 June 2011 16:18, Jimbo Massive <jimbo.massive-haskell at xyxyx.org> wrote:
>> > Or is this bad behaviour due to HUnit doing something unsafe?
>> I think it may be related to this bug:
>> The suggested fix is to change HUnit to define assertFailure with
>> throwIO, but the latest source code still uses throw:
>> So this could very well be a HUnit bug.
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> This mail sent through IMP: http://horde.org/imp/
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe