VMS syntax nit in new MakeMaker test.
[p5sagit/p5-mst-13.2.git] / t / op / incfilter.t
index 97ce37a..f796275 100644 (file)
@@ -5,6 +5,10 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = qw(. ../lib);
+    if ($ENV{PERL_CORE_MINITEST}) {
+        print "1..0 # Skip: no dynamic loading on miniperl\n";
+        exit 0;
+    }
     unless (find PerlIO::Layer 'perlio') {
        print "1..0 # Skip: not perlio\n";
        exit 0;
@@ -12,9 +16,10 @@ BEGIN {
     require "test.pl";
 }
 use strict;
+use Config;
 use Filter::Util::Call;
 
-plan(tests => 128);
+plan(tests => 141);
 
 unshift @INC, sub {
     no warnings 'uninitialized';
@@ -44,14 +49,17 @@ do \&generator or die;
 # Check that the array dereferencing works ready for the more complex tests:
 do [\&generator] or die;
 
-do [sub {
-       my $param = $_[1];
-       is (ref $param, 'ARRAY', "Got our parameter");
-       $_ = shift @$param;
-       return defined $_ ? 1 : 0;
-    }, ["pass('Can return generators which take state');\n",
-       "pass('And return multiple lines');\n",
-       ]] or die;
+sub generator_with_state {
+    my $param = $_[1];
+    is (ref $param, 'ARRAY', "Got our parameter");
+    $_ = shift @$param;
+    return defined $_ ? 1 : 0;
+}
+
+do [\&generator_with_state,
+    ["pass('Can return generators which take state');\n",
+     "pass('And return multiple lines');\n",
+    ]] or die;
    
 
 open $fh, "<", \'fail("File handles and filters work from \@INC");';
@@ -64,11 +72,24 @@ do [$fh, sub {s/$_[1]/pass/; return;}, 'fail'] or die;
 
 print "# 2 tests with pipes from subprocesses.\n";
 
-open $fh, 'echo pass|' or die $!;
+my ($echo_command, $pass_arg, $fail_arg);
+
+if ($^O eq 'VMS') {
+    $echo_command = 'write sys$output';
+    $pass_arg = '"pass"';
+    $fail_arg = '"fail"';
+}
+else {
+    $echo_command = 'echo';
+    $pass_arg = 'pass';
+    $fail_arg = 'fail';
+}
+
+open $fh, "$echo_command $pass_arg|" or die $!;
 
 do $fh or die;
 
-open $fh, 'echo fail|' or die $!;
+open $fh, "$echo_command $fail_arg|" or die $!;
 
 do [$fh, sub {s/$_[1]/pass/; return;}, 'fail'] or die;
 
@@ -153,7 +174,10 @@ BEGIN {prepend_block_counting_filter};
 pas("SSS make s fast SSS");
 EOC
 
-do [$fh, sub {s/s/ss/gs; s/([\nS])/$1$1$1/gs; return;}] or die;
+TODO: {
+    todo_skip "disabled under -Dmad", 50 if $Config{mad};
+    do [$fh, sub {s/s/ss/gs; s/([\nS])/$1$1$1/gs; return;}] or die;
+}
 
 sub prepend_line_counting_filter {
     filter_add(sub {
@@ -173,3 +197,27 @@ pass("You should see this line thrice");
 EOC
 
 do [$fh, sub {$_ .= $_ . $_; return;}] or die;
+
+do \"pass\n(\n'Scalar references are treated as initial file contents'\n)\n"
+or die;
+
+open $fh, "<", \"ss('The file is concatentated');";
+
+do [\'pa', $fh] or die;
+
+open $fh, "<", \"ff('Gur svygre vf bayl eha ba gur svyr');";
+
+do [\'pa', $fh, sub {tr/A-Za-z/N-ZA-Mn-za-m/; return;}] or die;
+
+open $fh, "<", \"SS('State also works');";
+
+do [\'pa', $fh, sub {s/($_[1])/lc $1/ge; return;}, "S"] or die;
+
+@lines = ('ss', '(', "'you can use a generator'", ')');
+
+do [\'pa', \&generator] or die;
+
+do [\'pa', \&generator_with_state,
+    ["ss('And generators which take state');\n",
+     "pass('And return multiple lines');\n",
+    ]] or die;