]> git.imager.perl.org - imager.git/blob - t/t57infix.t
Fixed missing myfree() in bmp.c.
[imager.git] / t / t57infix.t
1 BEGIN { $| = 1; print "1..7\n"; }
2 END {print "not ok 1\n" unless $loaded;}
3 use Imager::Expr;
4
5 $loaded = 1;
6 print "ok 1\n";
7
8 # only test this if Parse::RecDescent was loaded successfully
9 eval "use Parse::RecDescent";
10 if (!$@) {
11   my $opts = {expr=>'z=0.8;return hsv(x/w*360,y/h,z)', variables=>[ qw(x y) ], constants=>{h=>100,w=>100}};
12   my $expr = Imager::Expr->new($opts);
13   if ($expr) {
14     print "ok 2\n";
15     my $code = $expr->dumpcode();
16     my @code = split /\n/,$code;
17     #print $code;
18     print $code[-1] =~ /:\s+ret/ ? "ok 3\n" : "not ok 3\n";
19     print grep(/:\s+mult.*360/, @code) ? "ok 4\n" : "not ok 4\n";
20     # strength reduction converts these to mults
21     #print grep(/:\s+div.*x/, @code) ? "ok 5\n" : "not ok 5\n";
22     #print grep(/:\s+div.*y/, @code) ? "ok 6\n" : "not ok 6\n";
23     print grep(/:\s+mult.*x/, @code) ? "ok 5\n" : "not ok 5\n";
24     print grep(/:\s+mult.*y/, @code) ? "ok 6\n" : "not ok 6\n";
25     print grep(/:\s+hsv.*0\.8/, @code) ? "ok 7\n" : "not ok 7\n";
26   }
27   else {
28     print "not ok 2 # ",Imager::Expr::error(),"\n";
29     print "not ok 3 # skipped\n";
30     print "not ok 4 # skipped\n";
31     print "not ok 5 # skipped\n";
32     print "not ok 6 # skipped\n";
33     print "not ok 7 # skipped\n";
34   }
35 }
36 else {
37   print "ok 2 # skipped - no Parse::RecDescent\n";
38   print "ok 3 # skipped - no Parse::RecDescent\n";
39   print "ok 4 # skipped - no Parse::RecDescent\n";
40   print "ok 5 # skipped - no Parse::RecDescent\n";
41   print "ok 6 # skipped - no Parse::RecDescent\n";
42   print "ok 7 # skipped - no Parse::RecDescent\n";
43 }