Created
January 2, 2010 18:39
-
-
Save preaction/267600 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package t::Destroy; | |
use Moose; | |
use Test::Sweet; | |
use Try::Tiny; | |
test something { | |
my $do; | |
try { | |
# Works, because DESTROY doesn't run | |
#$do = t::DestroyObject->new; | |
# Doesn't work, because DESTROY causes $@ to get clobbered | |
my $do = t::DestroyObject->new; | |
$do->dies; | |
} | |
catch { | |
is( $_, "This is the message I want\n" ); | |
} | |
} | |
package t::DestroyObject; | |
use Moose; | |
sub dies { | |
die "This is the message I want\n"; | |
} | |
sub DESTROY { | |
# Under no circumstances can we allow this to run! | |
eval { die "This is NOT the message I want\n" }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use t::Destroy; | |
exit t::Destroy->new->run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment