summaryrefslogtreecommitdiff
path: root/t/op/override.t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-01-15 00:03:04 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2002-01-15 01:23:53 +0000
commit9b3023bc082e94b9899c0042ba030062098682a6 (patch)
tree6d94b2930c87893a42b97476460fc5d275f23850 /t/op/override.t
parent9ce38ebc6b92fe51912fbf2f7ebcca58be688dbe (diff)
downloadperl-9b3023bc082e94b9899c0042ba030062098682a6.tar.gz
[PATCH] Overriding readline() should also override <FH>
Date: Mon, 14 Jan 2002 23:03:04 +0100 Message-ID: <20020114230304.A691@rafael> Subject: Re: [PATCH] Overriding readline() should also override <FH> From: Rafael Garcia-Suarez <rgarciasuarez@free.fr> Date: Mon, 14 Jan 2002 23:18:43 +0100 Message-ID: <20020114231843.E691@rafael> p4raw-id: //depot/perl@14260
Diffstat (limited to 't/op/override.t')
-rwxr-xr-xt/op/override.t20
1 files changed, 19 insertions, 1 deletions
diff --git a/t/op/override.t b/t/op/override.t
index 590fcaa954..1a4e5e02f8 100755
--- a/t/op/override.t
+++ b/t/op/override.t
@@ -6,7 +6,7 @@ BEGIN {
push @INC, '../lib';
}
-print "1..11\n";
+print "1..17\n";
#
# This file tries to test builtin override using CORE::GLOBAL
@@ -70,3 +70,21 @@ print "ok 10\n";
print "not " if $r or $@ !~ /^Can't locate NoNeXiSt/i;
print "ok 11\n";
}
+
+#
+# readline() has special behaviour too
+#
+
+$r = 11;
+BEGIN { *CORE::GLOBAL::readline = sub (;*) { ++$r }; }
+print <FH> == 12 ? "ok 12\n" : "not ok 12\n";
+print <$fh> == 13 ? "ok 13\n" : "not ok 13\n";
+my $pad_fh;
+print <$pad_fh> == 14 ? "ok 14\n" : "not ok 14\n";
+
+# Non-global readline() override
+BEGIN { *Rgs::readline = sub (;*) { --$r }; }
+package Rgs;
+print <FH> == 13 ? "ok 15\n" : "not ok 15\n";
+print <$fh> == 12 ? "ok 16\n" : "not ok 16\n";
+print <$pad_fh> == 11 ? "ok 17\n" : "not ok 17\n";