develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34261 - in trunk/languages/lua/t: . pmc

From:
fperrad
Date:
December 22, 2008 15:00
Subject:
[svn:parrot] r34261 - in trunk/languages/lua/t: . pmc
Message ID:
20081222230005.80A46CBA12@x12.develooper.com
Author: fperrad
Date: Mon Dec 22 15:00:04 2008
New Revision: 34261

Modified:
   trunk/languages/lua/t/basic.t
   trunk/languages/lua/t/harness
   trunk/languages/lua/t/io.t
   trunk/languages/lua/t/lfs.t
   trunk/languages/lua/t/os.t
   trunk/languages/lua/t/package.t
   trunk/languages/lua/t/pmc/function.t
   trunk/languages/lua/t/regex.t
   trunk/languages/lua/t/shootout.t
   trunk/languages/lua/t/standalone.t
   trunk/languages/lua/t/test-from-lua.t

Log:
[Lua] Test
- now, all files used as resource by test are relative to $FindBin::Bin

Modified: trunk/languages/lua/t/basic.t
==============================================================================
--- trunk/languages/lua/t/basic.t	(original)
+++ trunk/languages/lua/t/basic.t	Mon Dec 22 15:00:04 2008
@@ -78,9 +78,9 @@
 /^[^:]+: [^:]+:\d+: bad argument #1 to 'collectgarbage' \(invalid option 'unknown'\)\nstack traceback:\n/
 OUTPUT
 
-unlink('../lib1.lua') if ( -f '../lib1.lua' );
+unlink("$FindBin::Bin/../../../lib1.lua") if ( -f "$FindBin::Bin/../../../lib1.lua" );
 my $X;
-open $X, '>', '../lib1.lua';
+open $X, '>', "$FindBin::Bin/../../../lib1.lua";
 print {$X} << 'CODE';
 function norm (x, y)
     return (x^2 + y^2)^0.5
@@ -109,7 +109,7 @@
 OUTPUT
 
 # clean up lib1.lua
-unlink('../lib1.lua') if ( -f '../lib1.lua' );
+unlink("$FindBin::Bin/../../../lib1.lua") if ( -f "$FindBin::Bin/../../../lib1.lua" );
 
 language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function dofile (no file)' );
 dofile("no_file.lua")
@@ -117,8 +117,8 @@
 /^[^:]+:( [^:]+:\d+:)? cannot open no_file.lua: No such file or directory\nstack traceback:\n/
 OUTPUT
 
-unlink('../foo.lua') if ( -f '../foo.lua' );
-open $X, '>', '../foo.lua';
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
+open $X, '>', "$FindBin::Bin/../../../foo.lua";
 print {$X} '?syntax error?';
 close $X;
 
@@ -129,7 +129,7 @@
 OUTPUT
 
 # clean up foo.lua
-unlink('../foo.lua') if ( -f '../foo.lua' );
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
 
 language_output_is( 'lua', <<'CODE', <<'OUT', 'function getfenv' );
 local function f () end
@@ -180,8 +180,8 @@
 nil	nil
 OUTPUT
 
-unlink('../foo.lua') if ( -f '../foo.lua' );
-open $X, '>', '../foo.lua';
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
+open $X, '>', "$FindBin::Bin/../../../foo.lua";
 print {$X} << 'CODE';
 function foo (x)
     print(x)
@@ -210,7 +210,7 @@
 OUTPUT
 
 # clean up foo.lua
-unlink('../foo.lua') if ( -f '../foo.lua' );
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
 
 language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function loadfile (no file)' );
 f, msg = loadfile("no_file.lua")
@@ -219,8 +219,8 @@
 /^nil\t.*cannot open no_file.lua: No such file or directory/
 OUTPUT
 
-unlink('../foo.lua') if ( -f '../foo.lua' );
-open $X, '>', '../foo.lua';
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
+open $X, '>', "$FindBin::Bin/../../../foo.lua";
 print {$X} '?syntax error?';
 close $X;
 
@@ -232,7 +232,7 @@
 OUTPUT
 
 # clean up foo.lua
-unlink('../foo.lua') if ( -f '../foo.lua' );
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function loadstring' );
 f = loadstring("i = i + 1")
@@ -654,7 +654,7 @@
 OUTPUT
 
 # clean up temporary files
-map { unlink("../tmp1.$_") if ( -f "../tmp1.$_" ) } qw(lua pbc pir);
+map { unlink("$FindBin::Bin/../../../tmp1.$_") if ( -f "$FindBin::Bin/../../../tmp1.$_" ) } qw(lua pbc pir);
 
 # Local Variables:
 #   mode: cperl

Modified: trunk/languages/lua/t/harness
==============================================================================
--- trunk/languages/lua/t/harness	(original)
+++ trunk/languages/lua/t/harness	Mon Dec 22 15:00:04 2008
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2007, The Perl Foundation.
+# Copyright (C) 2005-2008, The Perl Foundation.
 # $Id$
 
 =head1 NAME
@@ -7,13 +7,15 @@
 
 =head1 SYNOPSIS
 
-    cd languages && perl -I../lib -Ilua/t lua/t/harness --files
+    perl t/harness --files
 
-    cd languages && perl -I../lib -Ilua/t lua/t/harness
+    perl t/harness
 
-    cd languages && perl -I../lib -Ilua/t lua/t/harness lua/t/examples.t
+    perl t/harness --archive --send-to-smolder
 
-    cd languages && perl -I../lib lua/t/harness lua/t/pmc/nil.t
+    perl t/harness lua/t/examples.t
+
+    perl t/harness lua/t/pmc/nil.t
 
 =head1 DESCRIPTION
 
@@ -73,8 +75,8 @@
 
     # Only the Makefile in 'parrot/languages' uses --files
     my $dir = File::Spec->catfile( $language, 't' );
-    my @files = glob( File::Spec->catfile( $dir, 'pmc', '*.t' ) );
-    push @files, glob( File::Spec->catfile( $dir, 'type', '*.t' ) );
+    my @files;
+    push @files, glob( File::Spec->catfile( $dir, 'pmc', '*.t' ) );
     push @files, glob( File::Spec->catfile( $dir, '*.t' ) );
     print join( "\n", @files );
     print "\n" if scalar(@files);
@@ -98,11 +100,9 @@
             $dir = 't';
         }
         if ($dir) {
-            @files = glob( File::Spec->catfile( $dir, '*.t' ) );
             push @files, glob( File::Spec->catfile( $dir, 'pmc', '*.t' ) )
                 unless ($use_orig_lua);
-            push @files, glob( File::Spec->catfile( $dir, 'type', '*.t' ) )
-                unless ($use_orig_lua);
+            push @files, glob( File::Spec->catfile( $dir, '*.t' ) );
         }
     }
 

Modified: trunk/languages/lua/t/io.t
==============================================================================
--- trunk/languages/lua/t/io.t	(original)
+++ trunk/languages/lua/t/io.t	Mon Dec 22 15:00:04 2008
@@ -73,7 +73,7 @@
 true
 OUTPUT
 
-unlink('../file.no') if ( -f '../file.no' );
+unlink("$FindBin::Bin/../../../file.no") if ( -f "$FindBin::Bin/../../../file.no" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.open' );
 f, msg = io.open("file.no")
@@ -82,8 +82,8 @@
 nil	file.no: No such file or directory
 OUTPUT
 
-unlink('../file.txt') if ( -f '../file.txt' );
-open my $X, '>', '../file.txt';
+unlink("$FindBin::Bin/../../../file.txt") if ( -f "$FindBin::Bin/../../../file.txt" );
+open my $X, '>', "$FindBin::Bin/../../../file.txt";
 binmode $X, ':raw';
 print {$X} "file with text\n";
 close $X;
@@ -149,7 +149,7 @@
 CODE
 /^file \((0[Xx])?[0-9A-Fa-f]+\)/
 OUTPUT
-unlink('../output.new') if ( -f '../output.new' );
+unlink("$FindBin::Bin/../../../output.new") if ( -f "$FindBin::Bin/../../../output.new" );
 
 TODO: {
     local $TODO = 'pipe not yet implemented';
@@ -175,8 +175,8 @@
 file
 OUTPUT
 
-unlink('../number.txt') if ( -f '../number.txt' );
-open my $Y, '>', '../number.txt';
+unlink("$FindBin::Bin/../../../number.txt") if ( -f "$FindBin::Bin/../../../number.txt" );
+open my $Y, '>', "$FindBin::Bin/../../../number.txt";
 binmode $Y, ':raw';
 print {$Y} << 'DATA';
 6.0     -3.23   15e12
@@ -195,7 +195,7 @@
 1000001
 OUTPUT
 # clean up number.txt
-unlink('../number.txt') if ( -f '../number.txt' );
+unlink("$FindBin::Bin/../../../number.txt") if ( -f "$FindBin::Bin/../../../number.txt" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.lines filename' );
 for line in io.lines("file.txt") do
@@ -388,7 +388,7 @@
 OUTPUT
 
 # clean up file.txt
-unlink('../file.txt') if ( -f '../file.txt' );
+unlink("$FindBin::Bin/../../../file.txt") if ( -f "$FindBin::Bin/../../../file.txt" );
 
 language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'file:write closed' );
 f = io.open("file.out", "w")
@@ -407,7 +407,7 @@
 OUTPUT
 
 # clean up file.out
-unlink('../file.out') if ( -f '../file.out' );
+unlink("$FindBin::Bin/../../../file.out") if ( -f "$FindBin::Bin/../../../file.out" );
 
 # Local Variables:
 #   mode: cperl

Modified: trunk/languages/lua/t/lfs.t
==============================================================================
--- trunk/languages/lua/t/lfs.t	(original)
+++ trunk/languages/lua/t/lfs.t	Mon Dec 22 15:00:04 2008
@@ -24,8 +24,6 @@
 
 use Parrot::Test tests => 18;
 use Test::More;
-use Cwd;
-use File::Basename;
 use File::Spec;
 use Parrot::Test::Lua;
 
@@ -40,7 +38,7 @@
 LuaFileSystem 1.4.0
 OUT
 
-my $cwd = dirname(File::Spec->canonpath(getcwd));
+my $cwd = File::Spec->canonpath( "$FindBin::Bin/../../../" );
 language_output_is( 'lua', << 'CODE', << "OUT", 'function lfs.currentdir' );
 require "lfs"
 print(lfs.currentdir())
@@ -140,8 +138,8 @@
 No such file or directory
 OUT
 
-unlink('../file.txt') if ( -f '../file.txt' );
-open my $X, '>', '../file.txt';
+unlink("$FindBin::Bin/../../../file.txt") if ( -f "$FindBin::Bin/../../../file.txt" );
+open my $X, '>', "$FindBin::Bin/../../../file.txt";
 binmode $X, ':raw';
 print {$X} "file with text\n";
 close $X;
@@ -219,7 +217,7 @@
 OUT
 
 # clean up file.txt
-unlink('../file.txt') if ( -f '../file.txt' );
+unlink("$FindBin::Bin/../../../file.txt") if ( -f "$FindBin::Bin/../../../file.txt" );
 
 # Local Variables:
 #   mode: cperl

Modified: trunk/languages/lua/t/os.t
==============================================================================
--- trunk/languages/lua/t/os.t	(original)
+++ trunk/languages/lua/t/os.t	Mon Dec 22 15:00:04 2008
@@ -105,7 +105,7 @@
 GETENV_PARROT
 OUTPUT
 
-open my $X, '>', '../file.rm';
+open my $X, '>', "$FindBin::Bin/../../../file.rm";
 print {$X} 'file to remove';
 close $X;
 
@@ -116,8 +116,8 @@
 true
 OUTPUT
 
-ok( !-e '../file.rm', 'Test that the file is removed' );
-unlink('../file.rm') if ( -e '../file.rm' );
+ok( !-e "$FindBin::Bin/../../../file.rm", 'Test that the file is removed' );
+unlink("$FindBin::Bin/../../../file.rm") if ( -e "$FindBin::Bin/../../../file.rm" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function os.remove' );
 r, msg = os.remove("file.rm")
@@ -128,7 +128,7 @@
 file.rm: No such file or directory
 OUTPUT
 
-open $X, '>', '../file.old';
+open $X, '>', "$FindBin::Bin/../../../file.old";
 print {$X} 'file to rename';
 close $X;
 
@@ -139,10 +139,10 @@
 true
 OUTPUT
 
-ok( !-e '../file.old', 'Test that old file is missing' );
-ok( -e '../file.new', 'Test that new file is here' );
-unlink('../file.old') if ( -e '../file.old' );
-unlink('../file.new') if ( -e '../file.new' );
+ok( !-e "$FindBin::Bin/../../../file.old", 'Test that old file is missing' );
+ok( -e "$FindBin::Bin/../../../file.new", 'Test that new file is here' );
+unlink("$FindBin::Bin/../../../file.old") if ( -e "$FindBin::Bin/../../../file.old" );
+unlink("$FindBin::Bin/../../../file.new") if ( -e "$FindBin::Bin/../../../file.new" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function os.rename' );
 r, msg = os.rename("file.old", "file.new")

Modified: trunk/languages/lua/t/package.t
==============================================================================
--- trunk/languages/lua/t/package.t	(original)
+++ trunk/languages/lua/t/package.t	Mon Dec 22 15:00:04 2008
@@ -49,9 +49,9 @@
 hello world
 OUTPUT
 
-unlink('../complex.lua') if ( -f '../complex.lua' );
+unlink("$FindBin::Bin/../../../complex.lua") if ( -f "$FindBin::Bin/../../../complex.lua" );
 my $X;
-open $X, '>', '../complex.lua';
+open $X, '>', "$FindBin::Bin/../../../complex.lua";
 print {$X} << 'CODE';
 
 complex = {}
@@ -96,7 +96,7 @@
 OUTPUT
 
 # clean up complex.lua
-unlink('../complex.lua') if ( -f '../complex.lua' );
+unlink("$FindBin::Bin/../../../complex.lua") if ( -f "$FindBin::Bin/../../../complex.lua" );
 
 language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function require (no module)' );
 require "no_module"
@@ -104,8 +104,8 @@
 /^[^:]+: [^:]+:\d+: module 'no_module' not found:\n(\t.*\n)+stack traceback:\n/
 OUTPUT
 
-unlink('../foo.lua') if ( -f '../foo.lua' );
-open $X, '>', '../foo.lua';
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
+open $X, '>', "$FindBin::Bin/../../../foo.lua";
 print {$X} '?syntax error?';
 close $X;
 
@@ -116,7 +116,7 @@
 OUTPUT
 
 # clean up foo.lua
-unlink('../foo.lua') if ( -f '../foo.lua' );
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function require & package.preload' );
 foo = {}
@@ -133,8 +133,8 @@
 1234
 OUTPUT
 
-unlink('../foo.lua') if ( -f '../foo.lua' );
-open $X, '>', '../foo.lua';
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
+open $X, '>', "$FindBin::Bin/../../../foo.lua";
 print {$X} 'print("in foo.lua", ...)';
 close $X;
 
@@ -145,10 +145,10 @@
 OUTPUT
 
 # clean up foo.lua
-unlink('../foo.lua') if ( -f '../foo.lua' );
+unlink("$FindBin::Bin/../../../foo.lua") if ( -f "$FindBin::Bin/../../../foo.lua" );
 
-unlink('../complex.lua') if ( -f '../complex.lua' );
-open $X, '>', '../complex.lua';
+unlink("$FindBin::Bin/../../../complex.lua") if ( -f "$FindBin::Bin/../../../complex.lua" );
+open $X, '>', "$FindBin::Bin/../../../complex.lua";
 print {$X} << 'CODE';
 -- print("complex.lua", ...)
 -- module(...)
@@ -191,15 +191,15 @@
 OUTPUT
 
 # clean up complex.lua
-unlink('../complex.lua') if ( -f '../complex.lua' );
+unlink("$FindBin::Bin/../../../complex.lua") if ( -f "$FindBin::Bin/../../../complex.lua" );
 
 SKIP:
 {
 skip('only with Parrot', 1) if ($test_prog eq 'lua');
 
-unlink('../mod_foo.pbc') if ( -f '../mod_foo.pbc' );
-unlink('../mod_foo.pir') if ( -f '../mod_foo.pir' );
-open $X, '>', '../mod_foo.pir';
+unlink("$FindBin::Bin/../../../mod_foo.pbc") if ( -f "$FindBin::Bin/../../../mod_foo.pbc" );
+unlink("$FindBin::Bin/../../../mod_foo.pir") if ( -f "$FindBin::Bin/../../../mod_foo.pir" );
+open $X, '>', "$FindBin::Bin/../../../mod_foo.pir";
 print {$X} <<'PIR';
 .HLL 'Lua'
 .loadlib 'lua_group'
@@ -246,8 +246,8 @@
 }
 
 # clean up mod_foo.pbc and/or mod_foo.pir if necessary
-unlink('../mod_foo.pbc') if ( -f '../mod_foo.pbc' );
-unlink('../mod_foo.pir') if ( -f '../mod_foo.pir' );
+unlink("$FindBin::Bin/../../../mod_foo.pbc") if ( -f "$FindBin::Bin/../../../mod_foo.pbc" );
+unlink("$FindBin::Bin/../../../mod_foo.pir") if ( -f "$FindBin::Bin/../../../mod_foo.pir" );
 
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'table package.loaded' );
 t = {}
@@ -323,7 +323,7 @@
 OUTPUT
 
 # clean up temporary files
-map { unlink("../tmp1.$_") if ( -f "../tmp1.$_" ) } qw(lua pbc pir);
+map { unlink("$FindBin::Bin/../../../tmp1.$_") if ( -f "$FindBin::Bin/../../../tmp1.$_" ) } qw(lua pbc pir);
 
 # Local Variables:
 #   mode: cperl

Modified: trunk/languages/lua/t/pmc/function.t
==============================================================================
--- trunk/languages/lua/t/pmc/function.t	(original)
+++ trunk/languages/lua/t/pmc/function.t	Mon Dec 22 15:00:04 2008
@@ -397,7 +397,7 @@
 /x
 OUTPUT
 
-open my $X, '>', '../foo.pir';
+open my $X, '>', "$FindBin::Bin/../../../../foo.pir";
 print {$X} q{
   .HLL 'Lua'
   .loadlib 'lua_group'
@@ -437,7 +437,7 @@
 /x
 OUTPUT
 
-system("../parrot -o ../foo.pbc ../foo.pir");
+system("$FindBin::Bin/../../../../parrot -o $FindBin::Bin/../../../../foo.pbc $FindBin::Bin/../../../../foo.pir");
 
 pir_output_like( << 'CODE', << 'OUTPUT', 'from PBC load_bytecode' );
 .HLL 'Lua'
@@ -461,8 +461,8 @@
 /x
 OUTPUT
 
-unlink '../foo.pir';
-unlink '../foo.pbc';
+unlink "$FindBin::Bin/../../../../foo.pir";
+unlink "$FindBin::Bin/../../../../foo.pbc";
 
 pir_output_like( << 'CODE', << 'OUTPUT', 'from compilation' );
 .HLL 'Lua'

Modified: trunk/languages/lua/t/regex.t
==============================================================================
--- trunk/languages/lua/t/regex.t	(original)
+++ trunk/languages/lua/t/regex.t	Mon Dec 22 15:00:04 2008
@@ -63,7 +63,7 @@
 my $test_number = 0;
 
 foreach (@test_files) {
-    my $filename = File::Spec->catfile( 'lua', 't', $_ );
+    my $filename = "$FindBin::Bin/$_" ;
     open my $FH, '<', $filename
             or die "can't open $filename ($!)\n";
     while (<$FH>) {

Modified: trunk/languages/lua/t/shootout.t
==============================================================================
--- trunk/languages/lua/t/shootout.t	(original)
+++ trunk/languages/lua/t/shootout.t	Mon Dec 22 15:00:04 2008
@@ -29,7 +29,6 @@
 my $code;
 my $out;
 my $in;
-my @dir = ( 'lua', 't', 'shootout' );
 
 #
 #   k-nucleotide
@@ -40,9 +39,9 @@
 {
     local $TODO = 'k-nucleotide';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'knucleotide_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'knucleotide-output.txt' ));
-$in = File::Spec->catfile( 'languages', @dir, 'knucleotide-input.txt' );
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/knucleotide_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/knucleotide-output.txt" );
+$in = "$FindBin::Bin/shootout/knucleotide-input.txt";
 language_output_is( 'lua', $code, $out, 'k-nucleotide', params => "< $in" );
 }
 
@@ -51,8 +50,8 @@
 #       Naive iterative summation: power sin cos
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'partialsums_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'partialsums-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/partialsums_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/partialsums-output.txt" );
 language_output_is( 'lua', $code, $out, 'partial-sums', params => '25000');
 
 #
@@ -64,8 +63,8 @@
 {
     local $TODO = 'broken';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fasta_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fasta-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/fasta_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/fasta-output.txt" );
 language_output_is( 'lua', $code, $out, 'fasta', params => '1000' );
 }
 
@@ -78,8 +77,8 @@
 {
     local $TODO = 'pb with loadstring ?';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'pidigits_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'pidigits-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/pidigits_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/pidigits-output.txt" );
 language_output_is( 'lua', $code, $out, 'pidigits', params => '27' );
 }
 
@@ -88,8 +87,8 @@
 #       Indexed-access to boolean-sequence
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsieve_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsieve-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nsieve_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nsieve-output.txt" );
 language_output_is( 'lua', $code, $out, 'nsieve' );
 
 #
@@ -101,9 +100,9 @@
 {
     local $TODO = 'pb with string.gsub ?';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'regexdna_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'regexdna-output.txt' ));
-$in = File::Spec->catfile( 'languages', @dir, 'regexdna-input.txt' );
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/regexdna_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/regexdna-output.txt" );
+$in = "$FindBin::Bin/shootout/regexdna-input.txt";
 language_output_is( 'lua', $code, $out, 'regex-dna', params => "< $in" );
 }
 
@@ -116,8 +115,8 @@
 {
     local $TODO = 'broken';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsievebits.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nsievebits-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nsievebits.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nsievebits-output.txt" );
 language_output_is( 'lua', $code, $out, 'nsieve-bits' );
 }
 
@@ -130,8 +129,8 @@
 {
     skip('low memory', 1) unless ($test_prog eq 'lua');
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'recursive.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'recursive-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/recursive.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/recursive-output.txt" );
 language_output_is( 'lua', $code, $out, 'recursive', params => '3' );
 }
 
@@ -140,8 +139,8 @@
 #       Generate Mandelbrot set portable bitmap file
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'mandelbrot_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'mandelbrot-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/mandelbrot_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/mandelbrot-output.txt" );
 language_output_is( 'lua', $code, $out, 'mandelbrot', params => '200' );
 
 #
@@ -149,8 +148,8 @@
 #       Double-precision N-body simulation
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nbody_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'nbody-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nbody_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/nbody-output.txt" );
 language_output_is( 'lua', $code, $out, 'n-body', params => '1000' );
 
 #
@@ -162,8 +161,8 @@
 {
     skip('maximum recursion depth exceeded', 1) unless ($test_prog eq 'lua');
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'message_lua-2.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'message-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/message_lua-2.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/message-output.txt" );
 language_output_is( 'lua', $code, $out, 'cheap-concurrency', params => '10' );
 }
 
@@ -176,8 +175,8 @@
 {
     local $TODO = 'broken';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'spectralnorm_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'spectralnorm-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/spectralnorm_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/spectralnorm-output.txt" );
 language_output_is( 'lua', $code, $out, 'spectral-norm', params => '100' );
 }
 
@@ -190,8 +189,8 @@
 {
     local $TODO = 'broken';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'chameneos.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'chameneos-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/chameneos.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/chameneos-output.txt" );
 language_output_is( 'lua', $code, $out, 'chameneos', params => '100' );
 }
 
@@ -204,9 +203,9 @@
 {
     local $TODO = 'reverse-complement';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'revcomp_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'revcomp-output.txt' ));
-$in = File::Spec->catfile( 'languages', @dir, 'revcomp-input.txt' );
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/revcomp_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/revcomp-output.txt" );
+$in = "$FindBin::Bin/shootout/revcomp-input.txt";
 language_output_is( 'lua', $code, $out, 'reverse-complement', params => "< $in" );
 }
 
@@ -219,8 +218,8 @@
 {
     skip('low memory', 1) unless ($test_prog eq 'lua');
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'binarytrees_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'binarytrees-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/binarytrees_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/binarytrees-output.txt" );
 language_output_is( 'lua', $code, $out, 'binary-trees', params => '10' );
 }
 
@@ -229,8 +228,8 @@
 #       Indexed-access to tiny integer-sequence
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fannkuch_lua-3.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fannkuch-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/fannkuch_lua-3.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/fannkuch-output.txt" );
 language_output_is( 'lua', $code, $out, 'fannkuch', params => '7' );
 
 #
@@ -238,9 +237,9 @@
 #       Read lines, parse and sum integers
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sumcol.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sumcol-output.txt' ));
-$in = File::Spec->catfile( 'languages', @dir, 'sumcol-input.txt' );
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/sumcol.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/sumcol-output.txt" );
+$in = "$FindBin::Bin/shootout/sumcol-input.txt";
 language_output_is( 'lua', $code, $out, 'sum-file', params => "< $in" );
 
 #
@@ -248,8 +247,8 @@
 #       Measure 'hello world' program startup time
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'hello.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'hello-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/hello.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/hello-output.txt" );
 language_output_is( 'lua', $code, $out, 'startup' );
 
 #
@@ -261,8 +260,8 @@
 {
     local $TODO = 'pb with loadstring ?';
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'meteor_lua-4.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'meteor-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/meteor_lua-4.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/shootout/meteor-output.txt" );
 language_output_is( 'lua', $code, $out, 'meteor' );
 }
 

Modified: trunk/languages/lua/t/standalone.t
==============================================================================
--- trunk/languages/lua/t/standalone.t	(original)
+++ trunk/languages/lua/t/standalone.t	Mon Dec 22 15:00:04 2008
@@ -53,8 +53,8 @@
 /^lua[^:]*: [^:]+:\d+: /
 OUT
 
-unlink('../hello.lua') if ( -f '../hello.lua' );
-open my $X, '>', '../hello.lua';
+unlink("$FindBin::Bin/../../../hello.lua") if ( -f "$FindBin::Bin/../../../hello.lua" );
+open my $X, '>', "$FindBin::Bin/../../../hello.lua";
 print {$X} "print 'Hello World'\n";
 close $X;
 
@@ -65,20 +65,20 @@
 SKIP: {
 skip("need luac", 1) unless (`luac -v` =~ /^Lua 5\.1/);
 
-system("luac -o ../hello.luac ../hello.lua");
+system("luac -o $FindBin::Bin/../../../hello.luac $FindBin::Bin/../../../hello.lua");
 
 language_output_is( 'lua', undef, << 'OUTPUT', 'bytecode translation', params => "hello.luac"  );
 Hello World
 OUTPUT
 
-unlink('../hello.luac') if ( -f '../hello.luac' );
+unlink("$FindBin::Bin/../../../hello.luac") if ( -f "$FindBin::Bin/../../../hello.luac" );
 }
 
 language_output_is( 'lua', undef, << 'OUTPUT', 'redirect', params => "< hello.lua"  );
 Hello World
 OUTPUT
 
-unlink('../hello.lua') if ( -f '../hello.lua' );
+unlink("$FindBin::Bin/../../../hello.lua") if ( -f "$FindBin::Bin/../../../hello.lua" );
 
 language_output_like( 'lua', undef, << 'OUTPUT', 'no file', params => "no_file.lua"  );
 /^lua[^:]*: cannot open no_file.lua: No such file or directory$/
@@ -109,8 +109,8 @@
 OUT
 delete $ENV{LUA_INIT};
 
-unlink('../boot.lua') if ( -f '../boot.lua' );
-open $X, '>', '../boot.lua';
+unlink("$FindBin::Bin/../../../boot.lua") if ( -f "$FindBin::Bin/../../../boot.lua" );
+open $X, '>', "$FindBin::Bin/../../../boot.lua";
 print {$X} "print 'boot from boot.lua by LUA_INIT'\n";
 close $X;
 
@@ -122,8 +122,8 @@
 Hello World
 OUT
 
-unlink('../boot.lua') if ( -f '../boot.lua' );
-open $X, '>', '../boot.lua';
+unlink("$FindBin::Bin/../../../boot.lua") if ( -f "$FindBin::Bin/../../../boot.lua" );
+open $X, '>', "$FindBin::Bin/../../../boot.lua";
 print {$X} '?syntax error?';
 close $X;
 
@@ -134,7 +134,7 @@
 /^lua[^:]*: [^:]+:\d+: /
 OUT
 
-unlink('../boot.lua');
+unlink("$FindBin::Bin/../../../boot.lua");
 
 $ENV{LUA_INIT} = '@no_file.lua';
 language_output_like( 'lua', <<'CODE', <<'OUT', 'LUA_INIT no file' );

Modified: trunk/languages/lua/t/test-from-lua.t
==============================================================================
--- trunk/languages/lua/t/test-from-lua.t	(original)
+++ trunk/languages/lua/t/test-from-lua.t	Mon Dec 22 15:00:04 2008
@@ -53,7 +53,6 @@
 my $code;
 my $out;
 my $in;
-my @dir = ( 'lua', 't', 'test' );
 
 
 #
@@ -61,13 +60,13 @@
 #       bisection method for solving non-linear equations
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'bisect.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/bisect.lua" );
 if ($^O =~ /Win32/) {
-    $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'bisect-output-win32.txt' ));
+    $out = Parrot::Test::slurp_file( "$FindBin::Bin/test/bisect-output-win32.txt" );
     language_output_is( 'lua', $code, $out, 'bisect', todo => 'floating point format' );
 }
 else {
-    $out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'bisect-output-unix.txt' ));
+    $out = Parrot::Test::slurp_file( "$FindBin::Bin/test/bisect-output-unix.txt" );
     language_output_is( 'lua', $code, $out, 'bisect' );
 }
 
@@ -76,8 +75,8 @@
 #       temperature conversion table (celsius to farenheit)
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'cf.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'cf-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/cf.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/cf-output.txt" );
 language_output_is( 'lua', $code, $out, 'cf' );
 
 #
@@ -85,7 +84,7 @@
 #       echo command line arguments
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'echo.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/echo.lua" );
 language_output_like( 'lua', $code, << 'OUTPUT', 'echo', params => 'arg1 arg2' );
 /^
 0\t.*languages.lua.t.test-from-lua_3\.(lua|pir|luac\.pir)\n
@@ -99,8 +98,8 @@
 #       factorial without recursion
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'factorial.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'factorial-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/factorial.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/factorial-output.txt" );
 language_output_is( 'lua', $code, $out, 'factorial' );
 
 #
@@ -108,7 +107,7 @@
 #       fibonacci function with cache
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fib.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/fib.lua" );
 language_output_like( 'lua', $code, << 'OUTPUT', 'fib' );
 /^
 \tn\tvalue\ttime\tevals\n
@@ -122,8 +121,8 @@
 #       fibonacci numbers with coroutines and generators
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fibfor.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'fibfor-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/fibfor.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/fibfor-output.txt" );
 language_output_is( 'lua', $code, $out, 'fibfor' );
 
 #
@@ -131,7 +130,7 @@
 #       the first program in every language
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'hello.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/hello.lua" );
 language_output_like( 'lua', $code, << 'OUTPUT', 'hello' );
 /^Hello world, from Lua 5\.1( \(on Parrot\))?!/
 OUTPUT
@@ -145,8 +144,8 @@
 {
     skip('uses too much memory with default runcore', 1) unless ($test_prog eq 'lua');
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'life.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'life-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/life.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/life-output.txt" );
 language_output_is( 'lua', $code, $out, 'life' );
 }
 
@@ -156,7 +155,7 @@
 #
 
 $ENV{USER} = "user";
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'printf.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/printf.lua" );
 language_output_like( 'lua', $code, << 'OUTPUT', 'printf' );
 /^Hello user from Lua 5\.1( \(on Parrot\))? on /
 OUTPUT
@@ -166,7 +165,7 @@
 #       make global variables readonly
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'readonly.lua' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/readonly.lua" );
 language_output_like( 'lua', $code, << 'OUTPUT', 'readonly' );
 /^[^:]+: [^:]+:\d+: cannot redefine global variable `y'\nstack traceback:\n/
 OUTPUT
@@ -176,8 +175,8 @@
 #       the sieve of of Eratosthenes programmed with coroutines
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sieve.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sieve-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/sieve.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/sieve-output.txt" );
 language_output_is( 'lua', $code, $out, 'sieve' );
 
 #
@@ -185,8 +184,8 @@
 #       two implementations of a sort function
 #
 
-$code = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sort.lua' ));
-$out = Parrot::Test::slurp_file(File::Spec->catfile( @dir, 'sort-output.txt' ));
+$code = Parrot::Test::slurp_file( "$FindBin::Bin/test/sort.lua" );
+$out = Parrot::Test::slurp_file( "$FindBin::Bin/test/sort-output.txt" );
 language_output_is( 'lua', $code, $out, 'sort' );
 
 # Local Variables:



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About