Imager.pm
- change the list of documents in Imager.pm to move the document
names out of the =item lines so we can make them into links
+ - the scale() method now produces a warning when called in
+ void context.
=================================================================
my $img = Imager->new();
my $tmp = Imager->new();
+ unless (defined wantarray) {
+ warn "scale() called in void context - scale() returns the scaled image";
+ return;
+ }
+
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
if ($opts{xpixels} and $opts{ypixels} and $opts{'type'}) {
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
-BEGIN { $| = 1; print "1..6\n"; }
+BEGIN { $| = 1; print "1..7\n"; }
END {print "not ok 1\n" unless $loaded;}
use Imager qw(:all);
$scaleimg->write(file=>'testout/t40scale2.ppm',type=>'pnm') or print "failed: ",$scaleimg->{ERRSTR},"\n";
print "ok 6\n";
+# check for a warning when scale() is called in void context
+my $warning;
+local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+$img->scale(scalefactor=>0.25);
+print $warning =~ /void/ ? "ok 7\n" : "not ok 7\n";