Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix RT #81529 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Try to fix RT #81529 #8

wants to merge 1 commit into from

Conversation

pplu
Copy link

@pplu pplu commented Jan 30, 2015

I've written code to try to fix the case where you call throws_ok, the code doesn't die, and the test passes (RT#81529).

The test in t/Exception.t that doesn't throw ("throws_ok: normal exit matched") is failing due to this code change.

Just thought you'd like to consider this new behaviour, since the original (passing the test) is very confusing.

@pplu
Copy link
Author

pplu commented Dec 30, 2015

Hi, any thoughts on this?

@exodist
Copy link
Member

exodist commented Dec 30, 2015

I need to look a bit deeper. I suspect this will fail for code that actually throws a 0, or an empty string as an exception. Instead I think a fix will requite use of this pattern:

my $throws = !eval { $code->(); 1 };
my $error = $@;

0, empty string, and undef are all valid as exceptions, so ultimately throws_ok will need to see if the eval passes or fails.

$ perl -e 'die undef'; perl -e 'die ""'; perl -e 'die 0'
Died at -e line 1.
Died at -e line 1.
0 at -e line 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants