-#!./perl
+#!./perl -w
+
+require './test.pl';
+use strict;
#
# This test checks for $@ being set early during an exceptional
-# unwinding, and that this early setting doesn't affect the late
+# unwinding, and that this early setting does not affect the late
# setting used to emit the exception from eval{}. The early setting is
# a backward-compatibility hack to satisfy modules that were relying on
# the historical early setting in order to detect exceptional unwinding.
# unwinding has been developed.
#
-print "1..12\n";
-my $test_num = 0;
-sub ok {
- print $_[0] ? "" : "not ", "ok ", ++$test_num, "\n";
-}
-
{
package End;
sub DESTROY { $_[0]->() }
my $c = end { $uerr = $@; $@ = "t2\n"; };
1;
}; $err = $@;
-ok $uerr eq "";
-ok $val == 1;
-ok $err eq "";
+is($uerr, "", "\$@ false at start of 'end' block inside 'eval' block");
+is($val, 1, "successful return from 'eval' block");
+is($err, "", "\$@ still false after 'end' block inside 'eval' block");
$@ = "t0\n";
$val = eval {
my $c = end { $uerr = $@; $@ = "t2\n"; };
1;
}; $err = $@;
-ok $uerr eq "t1\n";
-ok $val == 1;
-ok $err eq "";
+is($uerr, "t1\n", "true value assigned to \$@ before 'end' block inside 'eval' block");
+is($val, 1, "successful return from 'eval' block");
+is($err, "", "\$@ still false after 'end' block inside 'eval' block");
$@ = "";
$val = eval {
};
1;
}; $err = $@;
-ok $uerr eq "t3\n";
-ok !defined($val);
-ok $err eq "t3\n";
+is($uerr, "t3\n");
+is($val, undef, "undefined return value from 'eval' block with 'die'");
+is($err, "t3\n");
$@ = "t0\n";
$val = eval {
};
1;
}; $err = $@;
-ok $uerr eq "t3\n";
-ok !defined($val);
-ok $err eq "t3\n";
+is($uerr, "t3\n");
+is($val, undef, "undefined return value from 'eval' block with 'die'");
+is($err, "t3\n");
-1;
+done_testing();