3 use Test::More tests => 7;
5 BEGIN { use_ok('Imager::Expr') }
7 # only test this if Parse::RecDescent was loaded successfully
10 Imager::Expr->type_registered('expr')
11 or skip("Imager::Expr::Infix not available", 6);
13 my $opts = {expr=>'z=0.8;return hsv(x/w*360,y/h,z)', variables=>[ qw(x y) ], constants=>{h=>100,w=>100}};
14 my $expr = Imager::Expr->new($opts);
15 ok($expr, "make infix expression")
16 or skip("Could not make infix expression", 5);
17 my $code = $expr->dumpcode();
18 my @code = split /\n/,$code;
20 ok($code[-1] =~ /:\s+ret/, "final op a ret");
21 ok(grep(/:\s+mult.*360/, @code), "mult by 360 found");
22 # strength reduction converts these to mults
23 #print grep(/:\s+div.*x/, @code) ? "ok 5\n" : "not ok 5\n";
24 #print grep(/:\s+div.*y/, @code) ? "ok 6\n" : "not ok 6\n";
25 ok(grep(/:\s+mult.*x/, @code), "mult by x found");
26 ok(grep(/:\s+mult.*y/, @code), "mult by y found");
27 ok(grep(/:\s+hsv.*0\.8/, @code), "hsv op found");