Subject: | Can't "last" from within a try { ... } |
Test suite:
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
use Test::NoWarnings;
use TryCatch;
my $count = 0;
for (1..2) {
$count++;
try {
last;
} catch ($e) {
print "Error";
}
}
is($count, 1, "only ran once");
Actual result:
1..2
not ok 1 - only ran once
# Failed test 'only ran once'
# at try.pl line 21.
# got: '2'
# expected: '1'
not ok 2 - no warnings
# Failed test 'no warnings'
# at /Library/Perl/5.10.0/Test/NoWarnings.pm line 45.
# There were 2 warning(s)
# Previous test 0 ''
# Exiting eval via last at try.pl line 15.
# at try.pl line 15
# eval {...} called at try.pl line 14
#
# ----------
# Previous test 0 ''
# Exiting eval via last at try.pl line 15.
# at try.pl line 15
# eval {...} called at try.pl line 14
#
# Looks like you failed 2 tests of 2.