1 # this doesn't need a new namespace - I hope
9 my $green=i_color_new(0,255,0,255);
10 my $blue=i_color_new(0,0,255,255);
11 my $red=i_color_new(255,0,0,255);
13 my $img=Imager::ImgRaw::new(150,150,3);
15 i_box_filled($img,70,25,130,125,$green);
16 i_box_filled($img,20,25,80,125,$blue);
17 i_arc($img,75,75,30,0,361,$red);
18 i_conv($img,[0.1, 0.2, 0.4, 0.2, 0.1]);
25 my $img = Imager->new;
32 my ($testnum, $count, $why) = @_;
34 $why = '' unless defined $why;
36 print "ok $_ # skip $why\n" for $testnum ... $testnum+$count-1;
40 my ($count, $why) = @_;
42 skipn($TESTNUM, $count, $why);
47 my ($ok, $comment) = @_;
49 return okn($TESTNUM++, $ok, $comment);
53 my ($num, $ok, $comment) = @_;
55 defined $num or confess "No \$num supplied";
56 defined $comment or confess "No \$comment supplied";
58 print "ok $num # $comment\n";
61 print "not ok $num # $comment\n";
68 my ($file, $comment) = @_;
86 my ($num, $str, $re, $comment) = @_;
88 my $match = defined($str) && $str =~ $re;
89 okn($num, $match, $comment);
91 print "# The value: ",_sv_str($str),"\n";
92 print "# did not match: qr/$re/\n";
98 my ($str, $re, $comment) = @_;
100 matchn($TESTNUM++, $str, $re, $comment);
104 my ($num, $left, $right, $comment) = @_;
107 if (!defined $left && defined $right
108 || defined $left && !defined $right) {
111 elsif (!defined $left && !defined $right) {
114 # the right of the || produces a string of \0 if $left is a PV
116 elsif (!length $left || ($left & ~$left) ||
117 !length $right || ($right & ~$right)) {
118 $match = $left eq $right;
121 $match = $left == $right;
123 okn($num, $match, $comment);
125 print "# the following two values were not equal:\n";
126 print "# value: ",_sv_str($left),"\n";
127 print "# other: ",_sv_str($right),"\n";
134 my ($left, $right, $comment) = @_;
136 isn($TESTNUM++, $left, $right, $comment);
142 if (defined $value) {
143 if (!length $value || ($value & ~$value)) {
144 $value =~ s/\\/\\\\/g;
145 $value =~ s/\r/\\r/g;
146 $value =~ s/\n/\\n/g;
147 $value =~ s/\t/\\t/g;
148 $value =~ s/\"/\\"/g;
149 $value =~ s/([^ -\x7E])/"\\x".sprintf("%02x", ord($1))/ge;
154 return $value; # a number