Permalink
Browse files

[lazy-k] Merge t/calc.t and t/cat.t into t/examples.t.

Bring lazy-k back into unified languages testing.


git-svn-id: http://svn.perl.org/parrot/trunk@35994 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 611da73 commit 993ca7961aa8b33c941bd846d60b7724aeb2da84 bernhard committed Jan 25, 2009
Showing with 59 additions and 94 deletions.
  1. +0 −47 t/calc.t
  2. +0 −47 t/cat.t
  3. +59 −0 t/examples.t
View
@@ -1,47 +0,0 @@
-# Copyright (C) 2005-2009, The Perl Foundation.
-# $Id$
-
-=head1 NAME
-
-t/calc.t - testing calc.lazy
-
-=head1 SYNOPSIS
-
- % cd languages/lazy-k && perl lazy-k/t/calc.t
-
-=head1 DESCRIPTION
-
-Test calc.lazy.
-
-=head1 AUTHOR
-
-Bernhard Schmalhofer - C<Bernhard.Schmalhofer@gmx.de>
-
-=cut
-
-use strict;
-use warnings;
-use FindBin;
-use lib "$FindBin::Bin/../../../lib";
-
-use Test::More tests => 1;
-use Parrot::Config qw(%PConfig);
-use File::Spec ();
-
-my $is_win32 = $^O eq 'MSWin32';
-
-my $parrot = File::Spec->catfile( File::Spec->updir(), File::Spec->updir(), $PConfig{test_prog} );
-my $lazy_k = "$parrot lazy.pbc";
-my $source_fn = 'examples/calc.lazy';
-
-# XXX This does not look portable.
-my $cmd;
-if ($is_win32) {
- # Don't quote the string on Windows, it is passed on literally
- $cmd = qq{echo 1+2*3 | $lazy_k $source_fn};
-}
-else {
- $cmd = qq{echo '1+2*3' | $lazy_k $source_fn};
-}
-
-is( `$cmd`, "7\n", 'calc.lazy' );
View
47 t/cat.t
@@ -1,47 +0,0 @@
-# Copyright (C) 2005-2009, The Perl Foundation.
-# $Id$
-
-=head1 NAME
-
-lazy-k/t/cat.t - testing cat.lazy
-
-=head1 SYNOPSIS
-
- % cd languages/lazy-k && perl t/cat.t
-
-=head1 DESCRIPTION
-
-Test cat.lazy.
-
-=head1 AUTHOR
-
-Bernhard Schmalhofer - C<Bernhard.Schmalhofer@gmx.de>
-
-=cut
-
-use strict;
-use warnings;
-use FindBin;
-use lib "$FindBin::Bin/../../../lib";
-
-use Test::More tests => 1;
-use Parrot::Config qw(%PConfig);
-use File::Spec ();
-
-my $is_win32 = $^O eq 'MSWin32';
-
-my $parrot = File::Spec->catfile( File::Spec->updir(), File::Spec->updir(), $PConfig{test_prog} );
-my $lazy_k = "$parrot lazy.pbc";
-my $source_fn = 'examples/cat.lazy';
-
-# XXX This does not look portable.
-my $cmd;
-if ($is_win32) {
- # Don't quote the string on Windows, it is passed on literally
- $cmd = qq{echo 1+2*3 | $lazy_k $source_fn};
-}
-else {
- $cmd = qq{echo '1+2*3' | $lazy_k $source_fn};
-}
-
-is( `$cmd`, "1+2*3\n", 'cat.lazy' );
View
@@ -0,0 +1,59 @@
+# Copyright (C) 2005-2009, The Perl Foundation.
+# $Id$
+
+=head1 NAME
+
+t/examples.t - testing the lazy-l code examples
+
+=head1 SYNOPSIS
+
+ % cd languages/lazy-k && perl t/examples.t
+
+=head1 DESCRIPTION
+
+Test calc.lazy and cat.lazy.
+powers.lazy is not tested, as the output is infinite.
+
+=head1 AUTHOR
+
+Bernhard Schmalhofer - C<Bernhard.Schmalhofer@gmx.de>
+
+=cut
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../../../lib";
+
+use Test::More tests => 2;
+use Parrot::Config qw(%PConfig);
+use File::Spec ();
+
+my $is_win32 = $^O eq 'MSWin32';
+my $parrot = File::Spec->catfile( $FindBin::Bin,
+ File::Spec->updir(),
+ File::Spec->updir(),
+ File::Spec->updir(),
+ $PConfig{test_prog} );
+my $lazy_k = $parrot . q{ } . File::Spec->catfile( $FindBin::Bin,
+ File::Spec->updir(),
+ 'lazy.pbc' );
+my $source_fn = 'examples/calc.lazy';
+my @test_cases = (
+ [ 'calc.lazy', '2*4+3', "11\n" ],
+ [ 'cat.lazy', '2*4+3', "2*4+3\n" ],
+);
+
+foreach (@test_cases) {
+ my ($code_fn, $in, $out) = @{$_};
+
+ my $code_path = File::Spec->catfile( $FindBin::Bin,
+ File::Spec->updir(),
+ 'examples',
+ $code_fn );
+ # XXX This does not look portable.
+ # Don't quote the string on Windows, it is passed on literally
+ my $cmd = $is_win32 ? qq{echo $in | $lazy_k $code_path}
+ : qq{echo '$in' | $lazy_k $code_path};
+ is( `$cmd`, $out, "$code_fn $in" );
+}

0 comments on commit 993ca79

Please sign in to comment.