summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-02-06 17:55:32 -0800
committerJesse Vincent <jesse@bestpractical.com>2010-02-06 18:02:34 -0800
commitd963bf01c4c4db296760b1148f98bf668efcaf58 (patch)
tree2cb11035e6ab5271b3ec9c18f6f33f980afc0003 /t
parent23d72198749db53785b1c67cd1a37697afb95fc0 (diff)
downloadperl-d963bf01c4c4db296760b1148f98bf668efcaf58.tar.gz
Improvements to 31c9a3 - CPAN code did depend on the previous behaviour of blessing filehandles into FileHandle
It turns out that it's not quite as simple as blessing into IO::File. If you do (just) that, then it breaks any existing code that does C<require IO::Handle;> to allow it to call methods on file handles, because they're blessed into IO::File, which isn't loaded. (Note this code doesn't assume that methods in IO::Seekable are there to be called) So, it all should work if you also set @IO::File:::ISA correctly? That way, code that assumes that methods from IO::Handle can be called will work. However, gv.c now starts complaining (but not failing) if IO::Handle, IO::Seekable and Exporter aren't present, because it goes looking for methods in them. So the solution seems to be to set @IO::File::ISA *and* create (empty) stashes for the other 3 packages. Patch appended, but not applied.
Diffstat (limited to 't')
-rw-r--r--t/op/filehandle.t25
-rw-r--r--t/op/ref.t4
-rw-r--r--t/op/stash.t4
3 files changed, 29 insertions, 4 deletions
diff --git a/t/op/filehandle.t b/t/op/filehandle.t
new file mode 100644
index 0000000000..408c6701c1
--- /dev/null
+++ b/t/op/filehandle.t
@@ -0,0 +1,25 @@
+#!./perl
+
+# There are few filetest operators that are portable enough to test.
+# See pod/perlport.pod for details.
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+plan 4;
+use FileHandle;
+
+my $str = "foo";
+open my $fh, "<", \$str;
+is <$fh>, "foo";
+
+eval {
+ $fh->seek(0, 0);
+ is $fh->tell, 0;
+ is <$fh>, "foo";
+};
+
+is $@, '';
diff --git a/t/op/ref.t b/t/op/ref.t
index aca94a3567..db43562999 100644
--- a/t/op/ref.t
+++ b/t/op/ref.t
@@ -193,8 +193,8 @@ for (
like ("$ref", qr/^$type\(0x[0-9a-f]+\)$/, "stringify for ref to $desc");
}
-is (ref *STDOUT{IO}, 'IO::Handle', 'IO refs are blessed into IO::Handle');
-like (*STDOUT{IO}, qr/^IO::Handle=IO\(0x[0-9a-f]+\)$/,
+is (ref *STDOUT{IO}, 'IO::File', 'IO refs are blessed into IO::File');
+like (*STDOUT{IO}, qr/^IO::File=IO\(0x[0-9a-f]+\)$/,
'stringify for IO refs');
# Test anonymous hash syntax.
diff --git a/t/op/stash.t b/t/op/stash.t
index 8ea829baa1..1296b8b363 100644
--- a/t/op/stash.t
+++ b/t/op/stash.t
@@ -10,9 +10,9 @@ BEGIN { require "./test.pl"; }
plan( tests => 31 );
# Used to segfault (bug #15479)
-fresh_perl_is(
+fresh_perl_like(
'%:: = ""',
- 'Odd number of elements in hash assignment at - line 1.',
+ qr/Odd number of elements in hash assignment at - line 1\./,
{ switches => [ '-w' ] },
'delete $::{STDERR} and print a warning',
);