]> git.imager.perl.org - imager.git/commitdiff
convert to Test::More
authorTony Cook <tony@develop=help.com>
Fri, 26 Oct 2007 10:35:49 +0000 (10:35 +0000)
committerTony Cook <tony@develop=help.com>
Fri, 26 Oct 2007 10:35:49 +0000 (10:35 +0000)
t/t57infix.t

index f448185e4aabab6e8dd3d90e67c07c13b8da82b0..3430c6bae7413a055aef6b39befd69b11c51fb5c 100644 (file)
@@ -1,43 +1,29 @@
-BEGIN { $| = 1; print "1..7\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Imager::Expr;
+#!perl -w
+use strict;
+use Test::More tests => 7;;
 
-$loaded = 1;
-print "ok 1\n";
+BEGIN { use_ok('Imager::Expr') }
 
 # only test this if Parse::RecDescent was loaded successfully
-eval "use Parse::RecDescent";
-if (!$@) {
+SKIP:
+{
+  eval "use Parse::RecDescent";
+  $@
+    and skip("No Parse::RecDescent", 6);
+
   my $opts = {expr=>'z=0.8;return hsv(x/w*360,y/h,z)', variables=>[ qw(x y) ], constants=>{h=>100,w=>100}};
   my $expr = Imager::Expr->new($opts);
-  if ($expr) {
-    print "ok 2\n";
-    my $code = $expr->dumpcode();
-    my @code = split /\n/,$code;
-    #print $code;
-    print $code[-1] =~ /:\s+ret/ ? "ok 3\n" : "not ok 3\n";
-    print grep(/:\s+mult.*360/, @code) ? "ok 4\n" : "not ok 4\n";
-    # strength reduction converts these to mults
-    #print grep(/:\s+div.*x/, @code) ? "ok 5\n" : "not ok 5\n";
-    #print grep(/:\s+div.*y/, @code) ? "ok 6\n" : "not ok 6\n";
-    print grep(/:\s+mult.*x/, @code) ? "ok 5\n" : "not ok 5\n";
-    print grep(/:\s+mult.*y/, @code) ? "ok 6\n" : "not ok 6\n";
-    print grep(/:\s+hsv.*0\.8/, @code) ? "ok 7\n" : "not ok 7\n";
-  }
-  else {
-    print "not ok 2 # ",Imager::Expr::error(),"\n";
-    print "not ok 3 # skipped\n";
-    print "not ok 4 # skipped\n";
-    print "not ok 5 # skipped\n";
-    print "not ok 6 # skipped\n";
-    print "not ok 7 # skipped\n";
-  }
-}
-else {
-  print "ok 2 # skipped - no Parse::RecDescent\n";
-  print "ok 3 # skipped - no Parse::RecDescent\n";
-  print "ok 4 # skipped - no Parse::RecDescent\n";
-  print "ok 5 # skipped - no Parse::RecDescent\n";
-  print "ok 6 # skipped - no Parse::RecDescent\n";
-  print "ok 7 # skipped - no Parse::RecDescent\n";
+  ok($expr, "make infix expression")
+    or skip("Could not make infix expression", 5);
+  my $code = $expr->dumpcode();
+  my @code = split /\n/,$code;
+  #print $code;
+  ok($code[-1] =~ /:\s+ret/, "final op a ret");
+  ok(grep(/:\s+mult.*360/, @code), "mult by 360 found");
+  # strength reduction converts these to mults
+  #print grep(/:\s+div.*x/, @code) ? "ok 5\n" : "not ok 5\n";
+  #print grep(/:\s+div.*y/, @code) ? "ok 6\n" : "not ok 6\n";
+  ok(grep(/:\s+mult.*x/, @code), "mult by x found");
+  ok(grep(/:\s+mult.*y/, @code), "mult by y found");
+  ok(grep(/:\s+hsv.*0\.8/, @code), "hsv op found");
 }