This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Get override.t working under minitest
[perl5.git] / t / op / incfilter.t
index 8a3fd63..905d819 100644 (file)
@@ -13,7 +13,7 @@ use strict;
 use Config;
 use Filter::Util::Call;
 
-plan(tests => 150);
+plan(tests => 153);
 
 unshift @INC, sub {
     no warnings 'uninitialized';
@@ -74,7 +74,12 @@ if ($^O eq 'VMS') {
     $fail_arg = '"fail"';
 }
 else {
-    $echo_command = 'echo';
+    if ($^O =~ /android/) {
+        $echo_command = q{sh -c 'echo $@' -- };
+    }
+    else {
+        $echo_command = 'echo';
+    }
     $pass_arg = 'pass';
     $fail_arg = 'fail';
 }
@@ -168,10 +173,7 @@ BEGIN {prepend_block_counting_filter};
 pas("SSS make s fast SSS");
 EOC
 
-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;
-}
+do [$fh, sub {s/s/ss/gs; s/([\nS])/$1$1$1/gs; return;}] or die;
 
 sub prepend_line_counting_filter {
     filter_add(sub {
@@ -241,9 +243,35 @@ is $origlines[0], "1\n+\n2\n", 'ink filters do not mangle cow buffers';
 do \&generator or die;
 like ${$::{the_array}}, qr/^ARRAY\(0x.*\)\z/,
    'setting $_ to ref in inc filter';
-@lines = ('$::the_array = "', *foo, '"');
+@lines = ('$::the_array = "', do { no warnings 'once'; *foo}, '"');
 do \&generator or die;
 is ${$::{the_array}}, "*main::foo", 'setting $_ to glob in inc filter';
+@lines = (
+    '$::the_array = "',
+     do { no strict; no warnings; *{"foo\nbar"}},
+    '"');
+do \&generator or die;
+is ${$::{the_array}}, "*main::foo\nbar",
+    'setting $_ to multiline glob in inc filter';
+
+sub TIESCALAR { bless \(my $thing = pop), shift }
+sub FETCH {${$_[0]}}
+my $done;
+do sub {
+    return 0 if $done;
+    tie $_, "main", '$::the_scalar = 98732';
+    return $done = 1;
+} or die;
+is ${$::{the_scalar}}, 98732, 'tying $_ in inc filter';
+@lines = ('$::the_scalar', '= "12345"');
+tie my $ret, "main", 1;
+do sub :lvalue {
+    return 0 unless @lines;
+    $_ = shift @lines;
+    return $ret;
+} or die;
+is ${$::{the_scalar}}, 12345, 'returning tied val from inc filter';
+
 
 # d8723a6a74b2c12e wasn't perfect, as the char * returned by SvPV*() can be
 # a temporary, freed at the next FREETMPS. And there is a FREETMPS in