]> git.imager.perl.org - imager.git/blobdiff - t/t58trans2.t
prefer static first
[imager.git] / t / t58trans2.t
index 39f7f7eeefacc780edd8374693ccf3ed9ebc70ad..b9ebf583f57cc54081650bab5fa168ff8aa2a4b4 100644 (file)
@@ -1,9 +1,11 @@
 #!perl -w
 use strict;
-use Test::More tests => 36;
+use Test::More tests => 40;
 BEGIN { use_ok('Imager'); }
 use Imager::Test qw(is_color3);
 
+-d "testout" or mkdir "testout";
+
 Imager::init('log'=>'testout/t58trans2.log');
 
 my $im1 = Imager->new();
@@ -134,6 +136,22 @@ EOS
 op_test('000000', <<'EOS', 50, 82, 0, 'exp log');
 1 exp log 50 * 0.5 + 0.5 exp 50 * 0 rgb
 EOS
+op_test('800000', <<'EOS', 128, 0, 0, 'det');
+1 0 0 1 det 128 * 1 1 1 1 det 128 * 0 rgb
+EOS
+op_test('FF80C0', <<'EOS', 127, 0, 0, 'sat');
+0 0 getp1 sat 255 * 0.01 + 0 0 rgb
+EOS
+
+
+{
+  my $empty = Imager->new;
+  my $good = Imager->new(xsize => 1, ysize => 1);
+  ok(!Imager::transform2({ rpnexpr => "x y getp1" }, $good, $empty),
+     "can't transform an empty image");
+  is(Imager->errstr, "transform2: empty input image (input image 2)",
+     "check error message");
+}
 
 use Imager::Transform;
 
@@ -168,7 +186,7 @@ sub op_test ($$$$$$) {
   {
     my $out = Imager::transform2({ rpnexpr => $code }, $im);
     unless ($out) {
-      fail("$comment: coult not compile $code - ".Imager->errstr);
+      fail("$comment: could not compile $code - ".Imager->errstr);
       return;
     }
     my $found = $out->getpixel(x => 0, y => 0);