tagged release 0.6.4
[parrot.git] / languages / lua / t / shootout.t
blobe144a887e4cdabf29acaa95da2ac4f25fc5e32a9
1 #! perl
2 # Copyright (C) 2007-2008, The Perl Foundation.
3 # $Id$
5 =head1 NAME
7 t/shootout.t - The Computer Language Shootout
9 =head1 SYNOPSIS
11     % perl -I../lib -Ilua/t lua/t/shootout.t
13 =head1 DESCRIPTION
15 See L<http://shootout.alioth.debian.org>.
17 =cut
19 use strict;
20 use warnings;
21 use FindBin;
22 use lib "$FindBin::Bin";
24 use Parrot::Test tests => 19;
25 use Test::More;
26 use Parrot::Test::Lua;
28 my $test_prog = Parrot::Test::Lua::get_test_prog();
29 my $code;
30 my $out;
31 my $in;
32 my @dir = ( 'lua', 't', 'shootout' );
35 #   k-nucleotide
36 #       Hashtable update and k-nucleotide strings
39 TODO:
41     local $TODO = 'k-nucleotide';
43 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'knucleotide_lua-2.lua' ));
44 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'knucleotide-output.txt' ));
45 $in = File::Spec->catfile( 'languages', @dir, 'knucleotide-input.txt' );
46 language_output_is( 'lua', $code, $out, 'k-nucleotide', params => "< $in" );
50 #   partial-sums
51 #       Naive iterative summation: power sin cos
54 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'partialsums_lua-3.lua' ));
55 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'partialsums-output.txt' ));
56 language_output_is( 'lua', $code, $out, 'partial-sums', params => '25000');
59 #   fasta
60 #       Generate and write random DNA sequences
63 TODO:
65     local $TODO = 'broken';
67 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fasta_lua-2.lua' ));
68 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fasta-output.txt' ));
69 language_output_is( 'lua', $code, $out, 'fasta', params => '1000' );
73 #   pidigits
74 #       Streaming arbitrary-precision arithmetic
77 TODO:
79     local $TODO = 'pb with loadstring ?';
81 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'pidigits_lua-2.lua' ));
82 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'pidigits-output.txt' ));
83 language_output_is( 'lua', $code, $out, 'pidigits', params => '27' );
87 #   nsieve
88 #       Indexed-access to boolean-sequence
91 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsieve_lua-3.lua' ));
92 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsieve-output.txt' ));
93 language_output_is( 'lua', $code, $out, 'nsieve' );
96 #   regex-dna
97 #       Match DNA 8-mers and substitute nucleotides for IUB codes
100 TODO:
102     local $TODO = 'pb with string.gsub ?';
104 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'regexdna_lua-3.lua' ));
105 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'regexdna-output.txt' ));
106 $in = File::Spec->catfile( 'languages', @dir, 'regexdna-input.txt' );
107 language_output_is( 'lua', $code, $out, 'regex-dna', params => "< $in" );
111 #   nsieve-bits
112 #       Indexed-access to bit-values
115 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsievebits.lua' ));
116 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsievebits-output.txt' ));
117 language_output_is( 'lua', $code, $out, 'nsieve-bits' );
120 #   recursive
121 #       Naive recursive-algorithms: ack fib tak
124 SKIP:
126     skip('low memory', 1) unless ($test_prog eq 'lua');
128 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'recursive.lua' ));
129 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'recursive-output.txt' ));
130 language_output_is( 'lua', $code, $out, 'recursive', params => '3' );
134 # mandelbrot
135 #       Generate Mandelbrot set portable bitmap file
138 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'mandelbrot_lua-2.lua' ));
139 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'mandelbrot-output.txt' ));
140 language_output_is( 'lua', $code, $out, 'mandelbrot', params => '200' );
143 #   n-body
144 #       Double-precision N-body simulation
147 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nbody_lua-2.lua' ));
148 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nbody-output.txt' ));
149 language_output_is( 'lua', $code, $out, 'n-body', params => '1000' );
152 #   cheap-concurrency
153 #       Send messages between linked threads
156 SKIP:
158     skip('maximum recursion depth exceeded', 1) unless ($test_prog eq 'lua');
160 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'message_lua-2.lua' ));
161 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'message-output.txt' ));
162 language_output_is( 'lua', $code, $out, 'cheap-concurrency', params => '10' );
166 #   spectral-norm
167 #       Eigenvalue using the power method
170 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'spectralnorm_lua-3.lua' ));
171 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'spectralnorm-output.txt' ));
172 language_output_is( 'lua', $code, $out, 'spectral-norm', params => '100' );
175 #   chameneos
176 #       Symmetrical thread rendez-vous requests
179 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'chameneos.lua' ));
180 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'chameneos-output.txt' ));
181 language_output_is( 'lua', $code, $out, 'chameneos', params => '100' );
184 #   reverse-complement
185 #       Read DAN sequences - write their reverse-complement
188 TODO:
190     local $TODO = 'reverse-complement';
192 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'revcomp_lua-3.lua' ));
193 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'revcomp-output.txt' ));
194 $in = File::Spec->catfile( 'languages', @dir, 'revcomp-input.txt' );
195 language_output_is( 'lua', $code, $out, 'reverse-complement', params => "< $in" );
199 #   binary-trees
200 #       Allocate and deallocate many many binary trees
203 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'binarytrees_lua-3.lua' ));
204 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'binarytrees-output.txt' ));
205 language_output_is( 'lua', $code, $out, 'binary-trees', params => '10' );
208 #   fannkuch
209 #       Indexed-access to tiny integer-sequence
212 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fannkuch_lua-3.lua' ));
213 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fannkuch-output.txt' ));
214 language_output_is( 'lua', $code, $out, 'fannkuch', params => '7' );
217 #   sum-file
218 #       Read lines, parse and sum integers
221 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sumcol.lua' ));
222 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sumcol-output.txt' ));
223 $in = File::Spec->catfile( 'languages', @dir, 'sumcol-input.txt' );
224 language_output_is( 'lua', $code, $out, 'sum-file', params => "< $in" );
227 #   startup
228 #       Measure 'hello world' program startup time
231 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'hello.lua' ));
232 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'hello-output.txt' ));
233 language_output_is( 'lua', $code, $out, 'startup' );
236 #   meteor-contest
240 TODO:
242     local $TODO = 'pb with loadstring ?';
244 $code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'meteor_lua-4.lua' ));
245 $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'meteor-output.txt' ));
246 language_output_is( 'lua', $code, $out, 'meteor' );
249 # Local Variables:
250 #   mode: cperl
251 #   cperl-indent-level: 4
252 #   fill-column: 100
253 # End:
254 # vim: expandtab shiftwidth=4: