summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-12 22:16:46 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-12 22:20:25 +0000
commit2353548ef4fdc07f036560213168410c87b73807 (patch)
tree3bf83a4e4be0e5dcb5c12e8820a07673ba75323d
parent7db8714f1745a8bf9fbf94b21672ba5e3577fd4f (diff)
downloadperl-2353548ef4fdc07f036560213168410c87b73807.tar.gz
Fix long-standing bug in t/op/inc.t, whereby ok() ignored a failed match.
Unlike test.pl and Test::More, the home-rolled ok() in t/op/inc.t didn't have a prototype. Hence its arguments are in *list* context, meaning that any match will return an *empty list* if it fails. Provided ok() was called with a second, true, parameter, the failed match would not be noticed, because ok() would register a test pass, because it would now be testing the (intended) second parameter. Add a prototype, and fix the logic for the tests affected. Fortunately this wasn't concealing any bugs.
-rw-r--r--t/op/inc.t12
1 files changed, 7 insertions, 5 deletions
diff --git a/t/op/inc.t b/t/op/inc.t
index 88a34b2cb8..5b6ede2778 100644
--- a/t/op/inc.t
+++ b/t/op/inc.t
@@ -6,7 +6,7 @@ print "1..56\n";
my $test = 1;
-sub ok {
+sub ok ($;$$) {
my ($pass, $wrong, $err) = @_;
if ($pass) {
print "ok $test\n";
@@ -224,9 +224,11 @@ for my $n (47..113) {
unless $start_p == $check;
}
- foreach ([$start_p, '++$i', 'pre-inc'], [$start_p, '$i++', 'post-inc'],
- [$start_n, '--$i', 'pre-dec'], [$start_n, '$i--', 'post-dec']) {
- my ($start, $action, $description) = @$_;
+ foreach ([$start_p, '++$i', 'pre-inc', 'inc'],
+ [$start_p, '$i++', 'post-inc', 'inc'],
+ [$start_n, '--$i', 'pre-dec', 'dec'],
+ [$start_n, '$i--', 'post-dec', 'dec']) {
+ my ($start, $action, $description, $act) = @$_;
foreach my $warn (0, 1) {
my $warn_line = ($warn ? 'use' : 'no') . " warnings 'imprecision';";
@@ -250,7 +252,7 @@ EOC
print STDERR "# $_" foreach @warnings;
}
foreach (@warnings) {
- unless (ok (/Lost precision when incrementing \d+/, $_)) {
+ unless (ok (/Lost precision when ${act}rementing -?\d+/, $_)) {
print STDERR "# $_"
}
}