Change 27811 by [EMAIL PROTECTED] on 2006/04/15 11:59:26 Add a test for source filters returned from code references in @INC.
Affected files ... ... //depot/perl/MANIFEST#1378 edit ... //depot/perl/t/op/incfilter.t#1 add Differences ... ==== //depot/perl/MANIFEST#1378 (text) ==== Index: perl/MANIFEST --- perl/MANIFEST#1377~27721~ 2006-04-05 05:56:10.000000000 -0700 +++ perl/MANIFEST 2006-04-15 04:59:26.000000000 -0700 @@ -3365,6 +3365,7 @@ t/op/hash.t See if the complexity attackers are repelled t/op/hashwarn.t See if warnings for bad hash assignments work t/op/inccode.t See if coderefs work in @INC +t/op/incfilter.t See if the source filters in [EMAIL PROTECTED] work t/op/inc.t See if inc/dec of integers near 32 bit limit work t/op/index.t See if index works t/op/int.t See if int works ==== //depot/perl/t/op/incfilter.t#1 (text) ==== Index: perl/t/op/incfilter.t --- /dev/null 2005-11-29 02:13:17.616583056 -0800 +++ perl/t/op/incfilter.t 2006-04-15 04:59:26.000000000 -0700 @@ -0,0 +1,62 @@ +#!./perl -w + +# Tests for the source filters in [EMAIL PROTECTED] + +BEGIN { + chdir 't' if -d 't'; + @INC = qw(. ../lib); + unless (find PerlIO::Layer 'perlio') { + print "1..0 # Skip: not perlio\n"; + exit 0; + } + require "test.pl"; +} +use strict; + +plan(tests => 12); + +unshift @INC, sub { + no warnings 'uninitialized'; + ref $_[1] eq 'ARRAY' ? @{$_[1]} : $_[1]; +}; + +my $fh; + +open $fh, "<", \'pass("Can return file handles from [EMAIL PROTECTED]");'; +do $fh; + +my @origlines = ("# This is a blank line\n", + "pass('Can return generators from [EMAIL PROTECTED]');\n", + "pass('Which return multiple lines');\n", + "1", + ); +my @lines = @origlines; +sub generator { + $_ = shift @lines; + # Return of 0 marks EOF + return defined $_ ? 1 : 0; +}; + +do \&generator; + [EMAIL PROTECTED] = @origlines; +# Check that the array dereferencing works ready for the more complex tests: +do [\&generator]; + +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", + ]]; + + +open $fh, "<", \'fail("File handles and filters work from [EMAIL PROTECTED]");'; + +do [$fh, sub {s/fail/pass/}]; + +open $fh, "<", \'fail("File handles and filters with state work from [EMAIL PROTECTED]");'; + +do [$fh, sub {s/$_[1]/pass/}, 'fail']; End of Patch.