Author: bernhard
Date: Wed Nov  9 12:31:22 2005
New Revision: 9869

Modified:
   trunk/t/examples/library.t
   trunk/t/examples/subs.t
Log:
Use example_output_is() in remaining t/examples/*.t


Modified: trunk/t/examples/library.t
==============================================================================
--- trunk/t/examples/library.t  (original)
+++ trunk/t/examples/library.t  Wed Nov  9 12:31:22 2005
@@ -28,10 +28,10 @@ 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 = (
+my %expected
+  = (
     'getopt_demo.imc'        =>  << 'END_EXPECTED',
 Hi, I am 'getopt_demo.imc'.
 
@@ -40,30 +40,13 @@ You haven't passed the option '--string'
 You haven't passed the option '--integer'. This is fine with me.
 All args have been parsed.
 END_EXPECTED
-                          );
-
-# Do the testing
-my %test_func = ( pasm => \&pasm_output_is,
-                  pir  => \&pir_output_is,
-                  imc  => \&pir_output_is );
-
-while ( my ( $example, $expected ) = each %expected )
-{
-    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
-                                       \z                   # at end of string
-                                     }ixms or Usage();
-    if ( defined $extension ) { 
-      $test_func{$extension}->($code, $expected, $code_fn);
-    }
-    else {
-      fail( "no extension recognized for $code_fn" );
-    }
+while ( my ( $example, $expected ) = each %expected ) {
+    example_output_is( "examples/library/$example", $expected );
 }
 
+my $PARROT = ".$PConfig{slash}$PConfig{test_prog}";
 
 # For testing md5sum.pir we need to pass a filename
 {
@@ -73,7 +56,6 @@ while ( my ( $example, $expected ) = eac
     is( $sum, "fb171bd1a17bf6cd08d73105ad738a35\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;

Modified: trunk/t/examples/subs.t
==============================================================================
--- trunk/t/examples/subs.t     (original)
+++ trunk/t/examples/subs.t     Wed Nov  9 12:31:22 2005
@@ -29,7 +29,8 @@ use Parrot::Test tests => 7;
 use Test::More;
 
 # Set up expected output for examples
-my %expected = (
+my %expected
+  = (
     'bsr_ret.pasm'        =>  << 'END_EXPECTED',
 Main
 TestSub
@@ -79,25 +80,8 @@ END_EXPECTED
     'sub3.imc'        =>  << 'END_EXPECTED',
 7 8 nine
 END_EXPECTED
-                          );
-
-# Do the testing
-my %test_func = ( pasm => \&pasm_output_is,
-                  pir  => \&pir_output_is,
-                  imc  => \&pir_output_is );
+   );
 
 while ( my ( $example, $expected ) = each %expected ) {
-    my $code_fn   = "examples/subs/$example";
-    my $code = Parrot::Test::slurp_file($code_fn);
-
-    my ( $extension ) = $example =~ m{ [.]                  # introducing 
extension
-                                       ( pasm | pir | imc ) # match and 
capture the extension
-                                       \z                   # at end of string
-                                     }ixms or Usage();
-    if ( defined $extension ) { 
-      $test_func{$extension}->($code, $expected, $code_fn);
-    }
-    else {
-      ok( defined $extension, "no extension recognized for $code_fn" );
-    }
+    example_output_is( "examples/subs/$example", $expected );
 }

Reply via email to