diff options
author | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2014-06-21 16:23:29 +0000 |
---|---|---|
committer | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2014-06-21 16:41:32 +0000 |
commit | 826af139e95c118234b3f5cbaeab5d162e476795 (patch) | |
tree | 5ae82cf8fde8b1a823128f4e9a5b01778db837cb | |
parent | 4077a6bc0ae42279f757dffc08ee68ba8ace9924 (diff) | |
download | perl-826af139e95c118234b3f5cbaeab5d162e476795.tar.gz |
Fix black Win32 smoke broken by my v5.21.1-11-g4077a6b
The problem with this was that I didn't test this on a system where $Q
was false. On those systems we not only warn about "Invalid conversion"
but also about the missing sprintf argument, as intended.
The test broke because the local __WARN__ handler would clobber the
"conversion" warning with the "missing" warning, the fix is easy, just
accumulate the warnings with ".=".
While poking at this I discovered a bug that's been here ever since the
test was added back in v5.10.0-1461-g53f65a9. If we emitted a warning on
systems where $Q was true we'd pass the test, this is because the empty
regex will match warnings, the test actually meant to use is() not
like(). It's also a bug that t/test.pl accepts non-regexes as the second
argument, Test::More doesn't:
$ perl -MTest::More -wle 'like "", ""'
not ok 1
# Failed test at -e line 1.
# '' doesn't look much like a regex to me.
# Tests were run but no plan was declared and done_testing() was not seen.
This change might cause some additional black smoke because we'll now be
detecting warnings that we previously ignored, but I don't think this'll
fail on systems where $Q is true.
-rw-r--r-- | t/op/sprintf2.t | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t index 5fd3cd7e95..4116237b60 100644 --- a/t/op/sprintf2.t +++ b/t/op/sprintf2.t @@ -297,9 +297,17 @@ my @tests = ( for my $t (@tests) { my($fmt, $nums) = @$t; for my $num (@$nums) { - my $w; local $SIG{__WARN__} = sub { $w = shift }; - is(sprintf($fmt, $num), $Q ? $num : $fmt, "quad: $fmt -> $num"); - like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$fmt"/, "warning: $fmt"); + my $w = ''; + local $SIG{__WARN__} = sub { $w .= shift }; + my $sprintf_got = sprintf($fmt, $num); + if ($Q) { + is($sprintf_got, $num, "quad: $fmt -> $num"); + is($w, '', "no warnings for: $fmt -> $num"); + } else { + is($sprintf_got, $fmt, "quad unsupported: $fmt -> $fmt"); + like($w, qr/Invalid conversion in sprintf: "$fmt"/, "got warning about invalid conversion from fmt : $fmt"); + like($w, qr/Missing argument in sprintf/, "got warning about missing argument in sprintf from fmt : $fmt"); + } } } |