2 # Copyright (C) 2007-2008, The Perl Foundation.
7 t/shootout.t - The Computer Language Shootout
11 % perl -I../lib -Ilua/t lua/t/shootout.t
15 See L<http://shootout.alioth.debian.org>.
22 use lib "$FindBin::Bin";
24 use Parrot::Test tests => 19;
26 use Parrot::Test::Lua;
28 my $test_prog = Parrot::Test::Lua::get_test_prog();
32 my @dir = ( 'lua', 't', 'shootout' );
36 # Hashtable update and k-nucleotide strings
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" );
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');
60 # Generate and write random DNA sequences
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' );
74 # Streaming arbitrary-precision arithmetic
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' );
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' );
97 # Match DNA 8-mers and substitute nucleotides for IUB codes
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" );
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' );
121 # Naive recursive-algorithms: ack fib tak
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' );
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' );
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' );
153 # Send messages between linked threads
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' );
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' );
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' );
185 # Read DAN sequences - write their reverse-complement
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" );
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' );
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' );
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" );
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' );
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' );
251 # cperl-indent-level: 4
254 # vim: expandtab shiftwidth=4: