Author: bernhard
Date: Thu Oct 13 11:56:52 2005
New Revision: 9479
Added:
trunk/examples/library/md5sum.pir
- copied, changed from r9478, trunk/examples/pir/md5sum.pir
trunk/examples/library/pcre.pir
- copied, changed from r9478, trunk/examples/pir/pcre.pir
Removed:
trunk/examples/pir/md5sum.pir
trunk/examples/pir/pcre.pir
Modified:
trunk/MANIFEST
trunk/t/examples/library.t
trunk/t/examples/pir.t
trunk/t/library/pcre.t
Log:
Move the examples pcre.pir and md5sum.pir
to examples/library
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Thu Oct 13 11:56:52 2005
@@ -588,6 +588,8 @@ examples/japh/japh7.pasm
examples/japh/japh8.pasm [main]doc
examples/japh/japh9.pasm [main]doc
examples/library/getopt_demo.imc [main]doc
+examples/library/md5sum.pir [main]doc
+examples/library/pcre.pir [main]doc
examples/mops/README [main]doc
examples/mops/mops.c [main]doc
examples/mops/mops.cs [main]doc
@@ -600,8 +602,6 @@ examples/mops/mops.rb
examples/mops/mops.scheme [main]doc
examples/pasm/fact.pasm [main]doc
examples/pir/mandel.pir [main]doc
-examples/pir/md5sum.pir [main]doc
-examples/pir/pcre.pir [main]doc
examples/pir/sudoku.pir [main]doc
examples/pni/PQt.C [main]doc
examples/pni/QtHelloWorld.pasm [main]doc
Copied: trunk/examples/library/md5sum.pir (from r9478,
trunk/examples/pir/md5sum.pir)
==============================================================================
--- trunk/examples/pir/md5sum.pir (original)
+++ trunk/examples/library/md5sum.pir Thu Oct 13 11:56:52 2005
@@ -2,11 +2,11 @@
=head1 NAME
-examples/pir/md5sum.imc - calculate MD5 checksums
+examples/library/md5sum.imc - calculate MD5 checksums
=head1 SYNOPSIS
- % ./parrot examples/pir/md5sum.pir filename [filename ...]
+ % ./parrot examples/library/md5sum.pir filename [filename ...]
=head1 DESCRIPTION
Copied: trunk/examples/library/pcre.pir (from r9478,
trunk/examples/pir/pcre.pir)
==============================================================================
--- trunk/examples/pir/pcre.pir (original)
+++ trunk/examples/library/pcre.pir Thu Oct 13 11:56:52 2005
@@ -3,11 +3,11 @@
=head1 NAME
-examples/pir/pcre.imc - Perl compatible regular expressions
+examples/library/pcre.imc - Perl compatible regular expressions
=head1 SYNOPSIS
- % ./parrot examples/pir/pcre.pir string pattern
+ % ./parrot examples/library/pcre.pir string pattern
=head1 DESCRIPTION
Modified: trunk/t/examples/library.t
==============================================================================
--- trunk/t/examples/library.t (original)
+++ trunk/t/examples/library.t Thu Oct 13 11:56:52 2005
@@ -14,12 +14,8 @@ t/examples/library.t - Test examples in
=head1 DESCRIPTION
-Test the examples in F<examples/assambly>.
-For now only a fex examples are included here.
+Test the examples in F<examples/library>.
-=head1 TODO
-
-Check on remaining examples.
=head1 SEE ALSO
@@ -28,8 +24,11 @@ F<t/examples/japh.t>
=cut
use strict;
-use Parrot::Test tests => 1;
+use Parrot::Test tests => 3;
use Test::More;
+use Parrot::Config;
+
+my $PARROT = ".$PConfig{slash}$PConfig{test_prog}";
# Set up expected output for examples
my %expected = (
@@ -50,8 +49,8 @@ my %test_func = ( pasm => \&pasm_output_
while ( my ( $example, $expected ) = each %expected )
{
- my $code_fn = "examples/library/$example";
- my $code = Parrot::Test::slurp_file($code_fn);
+ my $code_fn = "examples/library/$example";
+ my $code = Parrot::Test::slurp_file($code_fn);
my ( $extension ) = $example =~ m{ [.] # introducing
extension
( pasm | pir | imc ) # match and
capture the extension
@@ -61,6 +60,31 @@ while ( my ( $example, $expected ) = eac
$test_func{$extension}->($code, $expected, $code_fn);
}
else {
- ok( defined $extension, "no extension recognized for $code_fn" );
+ fail( "no extension recognized for $code_fn" );
}
}
+
+
+# For testing md5sum.pir we need to pass a filename
+{
+ my $md5sum_fn = "examples$PConfig{slash}library$PConfig{slash}md5sum.pir";
+ my $sample_fn = "examples$PConfig{slash}README";
+ my $sum = `$PARROT $md5sum_fn $sample_fn`;
+ is( $sum, "cba989d2bebdce8f56f69c3f0d54ae15\t$sample_fn\n", $md5sum_fn );
+}
+
+
+# Testing pcre.imc with a simple pattern, if we have PCRE
+my $cmd = ($^O =~ /MSWin32/) ? "pcregrep --version" : "pcre-config --version";
+my $has_pcre = Parrot::Test::run_command($cmd, STDERR => '/dev/null') == 0;
+SKIP:
+{
+ skip( "no pcre-config", 1 ) unless $has_pcre;
+ my $pcre_fn = "examples$PConfig{slash}library$PConfig{slash}pcre.pir";
+ my $test_out = `$PARROT $pcre_fn asdf as`;
+ is( $test_out, << 'END_EXPECTED', $pcre_fn );
+asdf =~ /as/
+1 match(es):
+as
+END_EXPECTED
+};
Modified: trunk/t/examples/pir.t
==============================================================================
--- trunk/t/examples/pir.t (original)
+++ trunk/t/examples/pir.t Thu Oct 13 11:56:52 2005
@@ -32,7 +32,7 @@ Bernhard Schmalhofer - <Bernhard.Schmalh
=cut
use strict;
-use Parrot::Test tests => 4;
+use Parrot::Test tests => 2;
use Test::More;
use Parrot::Config;
@@ -125,21 +125,3 @@ while ( my ( $example, $expected ) = eac
ok( defined $extension, "no extension recognized for $code_fn" );
}
}
-
-# For testing md5sum.pir we need to pass a filename
-{
- my $md5sum_fn = "examples$PConfig{slash}pir$PConfig{slash}md5sum.pir";
- my $sum = `$PARROT $md5sum_fn $md5sum_fn`;
- is( $sum, "0141db367bd8265f37926c16ccf5113a\t$md5sum_fn\n", $md5sum_fn );
-}
-
-# Testing pcre.imc with a simple pattern
-{
- my $pcre_fn = "examples$PConfig{slash}pir$PConfig{slash}pcre.pir";
- my $test_out = `$PARROT $pcre_fn asdf as`;
- is( $test_out, << 'END_EXPECTED', $pcre_fn );
-asdf =~ /as/
-1 match(es):
-as
-END_EXPECTED
-}
Modified: trunk/t/library/pcre.t
==============================================================================
--- trunk/t/library/pcre.t (original)
+++ trunk/t/library/pcre.t Thu Oct 13 11:56:52 2005
@@ -107,4 +107,4 @@ ok 4
ok 5
OUT
-}
+};