scaleX and scaleY methods now warn when called in void context.
http://rt.cpan.org/NoAuth/Bug.html?id=9672
- some test scripts have been modified to use Test::More, which is now
included under the t directory. Eventually all will be modified to use
Test::More and the duplicates in t/testtools.pl will be removed
+- the convert, crop, rotate, copy, matrix_transform, to_paletted, to_rgb8,
+ scaleX and scaleY methods now warn when called in void context.
+ http://rt.cpan.org/NoAuth/Bug.html?id=9672
=================================================================
my $self = shift;
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "copy() called in void context - copy() returns the copied image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
my $newcopy=Imager->new();
$newcopy->{IMG}=i_img_new();
i_copy($newcopy->{IMG},$self->{IMG});
sub crop {
my $self=shift;
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
-
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "crop() called in void context - crop() returns the cropped image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
my %hsh=@_;
my ($w, $h, $l, $r, $b, $t) =
$opts = shift;
}
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "to_paletted() called in void context - to_paletted() returns the converted image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
my $result = Imager->new;
$result->{IMG} = i_img_to_pal($self->{IMG}, $opts);
my $self = shift;
my $result;
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "to_rgb8() called in void context - to_rgb8() returns the cropped image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
if ($self->{IMG}) {
$result = Imager->new;
$result->{IMG} = i_img_to_rgb($self->{IMG})
my $self=shift;
my %opts=(scalefactor=>0.5,@_);
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "scaleX() called in void context - scaleX() returns the scaled image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
my $img = Imager->new();
my $self=shift;
my %opts=(scalefactor=>0.5,@_);
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "scaleY() called in void context - scaleY() returns the scaled image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
my $img = Imager->new();
sub rotate {
my $self = shift;
my %opts = @_;
+
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "rotate() called in void context - rotate() returns the rotated image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
if (defined $opts{right}) {
my $degrees = $opts{right};
if ($degrees < 0) {
my $self = shift;
my %opts = @_;
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "copy() called in void context - copy() returns the copied image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
if ($opts{matrix}) {
my $xsize = $opts{xsize} || $self->getwidth;
my $ysize = $opts{ysize} || $self->getheight;
my ($self, %opts) = @_;
my $matrix;
+ unless (defined wantarray) {
+ my @caller = caller;
+ warn "convert() called in void context - convert() returns the converted image at $caller[1] line $caller[2]\n";
+ return;
+ }
+
# the user can either specify a matrix or preset
# the matrix overrides the preset
if (!exists($opts{matrix})) {
use strict;
use lib 't';
-use Test::More tests=>93;
+use Test::More tests=>95;
BEGIN { use_ok(Imager => qw(:handy :all)) }
}
}
+{ # http://rt.cpan.org/NoAuth/Bug.html?id=9672
+ my $warning;
+ local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+ my $img = Imager->new(xsize=>10, ysize=>10);
+ $img->to_rgb8(); # doesn't really matter what the source is
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't01introvert\\.t', "correct file");
+}
+
sub check_add {
my ($im, $color, $expected) = @_;
my $index = Imager::i_addcolors($im, $color);
# some of this is tested in t01introvert.t too
use strict;
use lib 't';
-use Test::More tests => 57;
+use Test::More tests => 59;
BEGIN { use_ok("Imager"); }
my $img = Imager->new(xsize=>50, ysize=>50, type=>'paletted');
}
}
+{ # http://rt.cpan.org/NoAuth/Bug.html?id=9672
+ my $warning;
+ local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+ my $img = Imager->new(xsize=>10, ysize=>10);
+ $img->to_paletted();
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't023palette\\.t', "correct file");
+}
+
sub coloreq {
my ($left, $right, $comment) = @_;
#!perl -w
use strict;
use lib 't';
-use Test::More tests => 12;
+use Test::More tests => 16;
BEGIN { use_ok(Imager=>':all') }
$img->scale(scalefactor=>0.25);
cmp_ok($warning, '=~', qr/void/, "check warning");
cmp_ok($warning, '=~', qr/t40scale\.t/, "check filename");
+ $warning = '';
+ $img->scaleX(scalefactor=>0.25);
+ cmp_ok($warning, '=~', qr/void/, "check warning");
+ cmp_ok($warning, '=~', qr/t40scale\.t/, "check filename");
+ $warning = '';
+ $img->scaleY(scalefactor=>0.25);
+ cmp_ok($warning, '=~', qr/void/, "check warning");
+ cmp_ok($warning, '=~', qr/t40scale\.t/, "check filename");
}
{ # https://rt.cpan.org/Ticket/Display.html?id=7467
# segfault in Imager 0.43
#!perl -w
use strict;
use lib 't';
-use Test::More tests=>51;
+use Test::More tests=>57;
use Imager;
#$Imager::DEBUG=1;
}
}
+{ # http://rt.cpan.org/NoAuth/Bug.html?id=9672
+ my $warning;
+ local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+ my $img = Imager->new(xsize=>10, ysize=>10);
+ $img->copy();
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't64copyflip\\.t', "correct file");
+ $warning = '';
+ $img->rotate(degrees=>5);
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't64copyflip\\.t', "correct file");
+ $warning = '';
+ $img->matrix_transform(matrix=>[1, 1, 1]);
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't64copyflip\\.t', "correct file");
+}
+
#!perl -w
use strict;
use lib 't';
-use Test::More tests => 58;
+use Test::More tests => 60;
require "t/testtools.pl";
use Imager;
"and message");
}
+{ # http://rt.cpan.org/NoAuth/Bug.html?id=9672
+ my $warning;
+ local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+ my $img = Imager->new(xsize=>10, ysize=>10);
+ $img->crop(left=>5);
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't65crop\\.t', "correct file");
+}
use strict;
use Imager qw(:all :handy);
use lib 't';
-use Test::More tests=>17;
+use Test::More tests=>19;
Imager::init("log"=>'testout/t67convert.log');
"colour is as expected");
}
+{ # http://rt.cpan.org/NoAuth/Bug.html?id=9672
+ my $warning;
+ local $SIG{__WARN__} =
+ sub {
+ $warning = "@_";
+ my $printed = $warning;
+ $printed =~ s/\n$//;
+ $printed =~ s/\n/\n\#/g;
+ print "# ",$printed, "\n";
+ };
+ my $img = Imager->new(xsize=>10, ysize=>10);
+ $img->convert(preset=>"grey");
+ cmp_ok($warning, '=~', 'void', "correct warning");
+ cmp_ok($warning, '=~', 't67convert\\.t', "correct file");
+}