From: Tony Cook <tony@develop=help.com> Date: Fri, 26 Oct 2007 10:35:49 +0000 (+0000) Subject: convert to Test::More X-Git-Tag: Imager-0.61~14 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/90db0f79921e5b541d33ef07c40354e05965d427 convert to Test::More --- diff --git a/t/t57infix.t b/t/t57infix.t index f448185e..3430c6ba 100644 --- a/t/t57infix.t +++ b/t/t57infix.t @@ -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"); }