]>
Commit | Line | Data |
---|---|---|
90db0f79 TC |
1 | #!perl -w |
2 | use strict; | |
ff37fc3f | 3 | use Test::More tests => 7; |
02d1d628 | 4 | |
90db0f79 | 5 | BEGIN { use_ok('Imager::Expr') } |
02d1d628 AMH |
6 | |
7 | # only test this if Parse::RecDescent was loaded successfully | |
90db0f79 TC |
8 | SKIP: |
9 | { | |
ff37fc3f TC |
10 | Imager::Expr->type_registered('expr') |
11 | or skip("Imager::Expr::Infix not available", 6); | |
90db0f79 | 12 | |
02d1d628 AMH |
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); | |
90db0f79 TC |
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; | |
19 | #print $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"); | |
02d1d628 | 28 | } |