Acme-Chef

 view release on metacpan or  search on metacpan

script/compilechef  view on Meta::CPAN

     if not defined $full_path;

   open my $fh, '<', $full_path or die "Could not find $module in \@INC. ($!)";

   # $module_code .= "\npackage $module;\n";

   local $/ = "\n";

   while(<$fh>) {
      last if /^__END__$/;
      last if /^__DATA__$/;
      s/^use Acme::Chef::\w+;.*//;
      $module_code .= $_;
   }

   $module_code .= "\n";

   close $fh;
}

my $dump = $compiled->dump('autorun');

t/01hello.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Hello world';
my $expected_result = 'Hello world!';

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.");

t/01hello.t  view on Meta::CPAN


$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__


Hello World Souffle.

This recipe prints the immortal words "Hello world!", in a basically
brute force way. It also makes a lot of food for one person.

Ingredients.
72 g haricot beans
101 eggs

t/02helloliquefy.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Hello world';
my $expected_result = 'Hello world!';

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.");

t/02helloliquefy.t  view on Meta::CPAN


$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__


Hello World Souffle.

This recipe prints the immortal words "Hello world!", in a basically
brute force way. It also makes a lot of food for one person.

Ingredients.
72 g haricot beans
101 eggs

t/03bowlquantifier.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Dish quantifier';
my $expected_result = 'HHHH';

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.");

t/03bowlquantifier.t  view on Meta::CPAN


$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__


Many bowls.

This recipe uses many bowls.

Ingredients.
72 g letter H

Method.

t/06addto2ndbowl.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Add to 2nd bowl';
my $expected_result = ' 2';

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.");

t/06addto2ndbowl.t  view on Meta::CPAN


$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__


Add to 2nd bowl.

Ingredients.
1 apfel
1 birne

Method.
Put apfel into 1st mixing bowl. Add birne to 1st mixing bowl. Pour contents of the mixing bowl into the baking dish.

t/11japh.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'JAPH';
my $expected_result = 'Just another Chef/Perl Hacker,';

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.");

t/11japh.t  view on Meta::CPAN


$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__



JAPH Souffle.

Ingredients.
44 potatoes
114 onions
101 g flour
107 kg salt

t/21exp.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Exponentiation';
my $expected_result = ' 8';

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.");

t/21exp.t  view on Meta::CPAN

$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__

Exponentiation cake.

Calculate exponentiation: sugar ^ flour.

Ingredients.
3 kg flour
2 g sugar
1 egg

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

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.");

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


$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.

t/31fac.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'Factorial';
my $expected_result = ' 1 2 6 24 120 720 5040 40320 362880 3628800 39916800 479001600';

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.");

t/31fac.t  view on Meta::CPAN


$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__


Factorial.

Ingredients.
12 cups vodka
1 bucket
1 toilet

Method.

t/41stdin.t  view on Meta::CPAN

use Acme::Chef;

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

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

my $testname        = 'STDIN-Test';
my $expected_result = ' 10';

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

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

local $| = 1;
*OLDSTDIN = *STDIN;

(*STDIN) = tempfile(UNLINK => 1);

print STDIN "10\n";

t/41stdin.t  view on Meta::CPAN


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

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

close STDIN;
*STDIN = *OLDSTDIN;
ok(1, "Restored STDIN.");

__DATA__

STDIN stew.

Read flour from STDIN and output it.

Ingredients.
flour

Method.
Take flour from refrigerator.



( run in 1.307 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )