in reply to Test::More fails on foreach loop

What does parse() return?

I'm not being flippant; ok() expects a boolean. If the method returns something which coerces to a true value, that test assertion will pass.

If you want to continue to use the ok() assertion, make the method return a boolean value in all normal cases.

Update: I posted before I wrote what I really want to write: in the absence of an explicit return, the method will perform an implicit return of the last expression evaluated. Sometimes that's okay, but in this case it's not what you want.

Replies are listed 'Best First'.
Re^2: Test::More fails on foreach loop
by Notdeadyet (Initiate) on Mar 16, 2011 at 19:50 UTC
    Ok. Returning 1 fixed the issue. Thanks for helping me understand.
      Not really. Now you have a test that can't possibly fail. You want
      # Not ok if parse throws an exception. ok(eval { $xbrl->parse($incoming_file); 1 });
        Thanks for your help!