]> git.imager.perl.org - imager.git/blob - t/t56postfix.t
Imager 0.58 release
[imager.git] / t / t56postfix.t
1 BEGIN { $| = 1; print "1..6\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 #$Imager::DEBUG=1;
9
10 my $expr = Imager::Expr->new({rpnexpr=><<EXPR, variables=>[ qw(x y) ], constants=>{one=>1, two=>2}});
11 x two * # see if comments work
12 y one + 
13 getp1
14 EXPR
15 if ($expr) {
16   print "ok 2\n";
17
18   # perform some basic validation on the code
19   my $code = $expr->dumpcode();
20   my @code = split /\n/, $code;
21   print $code[-1] =~ /:\s+ret/ ? "ok 3\n" : "not ok 3\n";
22   print grep(/:\s+mult.*x/, @code) ? "ok 4\n" : "not ok 4\n";
23   print grep(/:\s+add.*y/, @code) ? "ok 5\n" : "not ok 5\n";
24   print grep(/:\s+getp1/, @code) ? "ok 6\n" : "not ok 6\n";
25 }
26 else {
27   print "not ok 2 ",Imager::Expr::error(),"\n";
28   print "not ok 3 # skip\n";
29   print "not ok 4 # skip\n";
30   print "not ok 5 # skip\n";
31   print "not ok 6 # skip\n";
32 }