inserting befunge program
[polyglot.git] / lib / FiboTest.pm
bloba873b2491ea7c825e538765b2636fdea30ee4084
1 package FiboTest;
3 use File::Copy;
4 use File::Path qw{ mkpath rmtree };
5 use FindBin qw{ $Bin };
6 use Test::More tests => 1;
8 use parent qw{ Exporter };
9 our @EXPORT = qw{ fibo_check };
11 # fibo_check( $lang, $ext, $cmd )
12 sub fibo_check {
13 my ($lang, $ext, $cmd) = @_;
15 # clean room for the test
16 my $dir = "$Bin/tmp/$lang";
17 rmtree($dir);
18 mkpath($dir);
20 # get expected result
21 my $want = do { local $/; <DATA> };
23 # run the test
24 copy( "$Bin/../fibonacci.txt", "$dir/fibonacci.$ext");
25 my $command = sprintf "cd $dir; $cmd 2>&1", "fibonacci.$ext";
26 my $have = qx{ $command };
28 is( $have, $want, "language $lang test");
30 # clean after ourselve
31 rmtree($dir) unless $ENV{POLYGLOT_DEBUG};
36 __DATA__