Acme-Chef

 view release on metacpan or  search on metacpan

t/25long.t  view on Meta::CPAN

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use strict;
use warnings;

use lib 'lib';

use Test::More tests => 8;

use Acme::Chef;

ok(1, "Module compiled."); # If we made it this far, we're ok.

#########################

my $testname        = 'Long test';
my $expected_result = ' 97 98 99 94 95 96 93 90 91 92';

local $/ = undef;
my $code = <DATA>;

my $compiled = Acme::Chef->compile( $code );
ok(ref $compiled eq 'Acme::Chef', "$testname code compiled.");

my $result = $compiled->execute();
ok($result eq $expected_result, "Correct result.");

my $dump = $compiled->dump();
ok((defined $dump and not ref $dump), "Dumped.");

local $@ = undef;
my $reconstructed = eval $dump;
ok((not $@ and ref $reconstructed eq 'Acme::Chef'), "Reconstruction from dump successful.");

$result = $reconstructed->execute();
ok($result eq $expected_result, "Correct result after reconstruction.");

$dump = $compiled->dump('autorun');
ok((defined $dump and not ref $dump), "Dumped with autorun enabled.");

$result = eval $dump;
ok((not $@ and $result eq $expected_result), "Correct result after reconstruction.");

__DATA__


Long test.

Ingredients.
100 kg time
100 lines of code
1 number

Method.
Put time into 1st mixing bowl.
Put time into 2nd mixing bowl.
Put time into 3rd mixing bowl.
Put time into 4th mixing bowl.
Put time into 5th mixing bowl.
Put time into 6th mixing bowl.
Put time into 7th mixing bowl.
Put time into 8th mixing bowl.
Put time into 9th mixing bowl.
Put time into 10th mixing bowl.
Remove number from 1st mixing bowl.
Remove number from 2nd mixing bowl.



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