Piet-Interpreter

 view release on metacpan or  search on metacpan

test.pl  view on Meta::CPAN

#!/usr/local/bin/perl -w

use Test;
BEGIN { plan tests => 39, onfail => sub { print "\n*** Tests failed! ***\n" } };
END   { print "not ok 1\n" unless $loaded }

use Image::Magick;
ok(1);

use Piet::Interpreter;
$loaded = 1;

my $h = Piet::Interpreter->new(codel_size => 10,
                               image      => 'testimg/hello2big.gif', );
print "\nRunning hello:\n";
print "Codel size = $h->{_codel_size}, ";
ok($h->codel_size,10);
$h->run;
ok(1);

print "\nRunning count:\n";
my $p = Piet::Interpreter->new;
$p->image('testimg/count.gif');
$p->run;

ok(1);

print "\nTesting PVM state:\n";

#  testimg/count.gif  (10 x 18)
#    Codel Size:  1
#    Step:  0   CX:  5   CY:  5   DP:  3   CC:  -1
#    Last color:  light red
#    Stack:  10,32

print "File = $p->{_filename}, ";
ok($p->filename,'testimg/count.gif');
print "Cols = $p->{_cols}, ";
ok($p->cols,10);
print "Rows = $p->{_rows}, ";
ok($p->rows,18);

print "CX = $p->{_cx}, ";
ok($p->{_cx},5);
print "CY = $p->{_cy}, ";
ok($p->{_cy},5);
print "DP = $p->{_dp}, ";
ok($p->{_dp},3);
print "CC = $p->{_cc}, ";
ok($p->{_cc},-1);

print "Last Color = $p->{_last_color}, ";
ok($p->{_last_color},'FFC0C0');

print "Stack = ";
$stack = join",",$p->_stack;
ok($stack, '10,32');


print "\nTesting reset:\n";

$p->reset;

ok($p->{_cx},0);
ok($p->{_cy},0);
ok($p->{_dp},0);
ok($p->{_cc},-1);



( run in 1.988 second using v1.01-cache-2.11-cpan-39bf76dae61 )