summaryrefslogtreecommitdiff
path: root/t/io
diff options
context:
space:
mode:
authorBen Morrow <ben@morrow.me.uk>2008-06-28 18:00:17 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-06-28 21:06:57 +0000
commit6e592b3a92f7ee35c9a857bd9a43297ab1693599 (patch)
tree262d198509e9c5efd2b2af3fcebb6daa6456c827 /t/io
parent087986a76c08e8dfaaee54f8f476bfa315216671 (diff)
downloadperl-6e592b3a92f7ee35c9a857bd9a43297ab1693599.tar.gz
Some more missing isGV_with_GP()s
Message-ID: <20080628160017.GA81579@osiris.mauzo.dyndns.org> p4raw-id: //depot/perl@34092
Diffstat (limited to 't/io')
-rw-r--r--t/io/pvbm.t81
1 files changed, 81 insertions, 0 deletions
diff --git a/t/io/pvbm.t b/t/io/pvbm.t
new file mode 100644
index 0000000000..6c97edf4e3
--- /dev/null
+++ b/t/io/pvbm.t
@@ -0,0 +1,81 @@
+#!./perl
+
+# Test that various IO functions don't try to treat PVBMs as
+# filehandles. Most of these will segfault perl if they fail.
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = qw(. ../lib);
+ require "./test.pl";
+}
+
+BEGIN { $| = 1 }
+
+plan(28);
+
+sub PVBM () { 'foo' }
+{ my $dummy = index 'foo', PVBM }
+
+{
+ my $which;
+ {
+ package Tie;
+
+ sub TIEHANDLE { $which = 'TIEHANDLE' }
+ sub TIESCALAR { $which = 'TIESCALAR' }
+ }
+ my $pvbm = PVBM;
+
+ tie $pvbm, 'Tie';
+ is ($which, 'TIESCALAR', 'PVBM gets TIESCALAR');
+}
+
+{
+ my $pvbm = PVBM;
+ ok (scalar eval { untie $pvbm; 1 }, 'untie(PVBM) doesn\'t segfault');
+ ok (scalar eval { tied $pvbm; 1 }, 'tied(PVBM) doesn\'t segfault');
+}
+
+{
+ my $pvbm = PVBM;
+
+ ok (scalar eval { pipe $pvbm, PIPE; }, 'pipe(PVBM, ) succeeds');
+ close foo;
+ close PIPE;
+ ok (scalar eval { pipe PIPE, $pvbm; }, 'pipe(, PVBM) succeeds');
+ close foo;
+ close PIPE;
+ ok (!eval { pipe \$pvbm, PIPE; }, 'pipe(PVBM ref, ) fails');
+ ok (!eval { pipe PIPE, \$pvbm; }, 'pipe(, PVBM ref) fails');
+
+ ok (!eval { truncate $pvbm, 0 }, 'truncate(PVBM) fails');
+ ok (!eval { truncate \$pvbm, 0}, 'truncate(PVBM ref) fails');
+
+ ok (!eval { stat $pvbm }, 'stat(PVBM) fails');
+ ok (!eval { stat \$pvbm }, 'stat(PVBM ref) fails');
+
+ ok (!eval { lstat $pvbm }, 'lstat(PVBM) fails');
+ ok (!eval { lstat \$pvbm }, 'lstat(PVBM ref) fails');
+
+ ok (!eval { chdir $pvbm }, 'chdir(PVBM) fails');
+ ok (!eval { chdir \$pvbm }, 'chdir(pvbm ref) fails');
+
+ ok (!eval { close $pvbm }, 'close(PVBM) fails');
+ ok (!eval { close $pvbm }, 'close(PVBM ref) fails');
+
+ ok (!eval { chmod 0600, $pvbm }, 'chmod(PVBM) fails');
+ ok (!eval { chmod 0600, \$pvbm }, 'chmod(PVBM ref) fails');
+
+ ok (!eval { chown 0, 0, $pvbm }, 'chown(PVBM) fails');
+ ok (!eval { chown 0, 0, \$pvbm }, 'chown(PVBM ref) fails');
+
+ ok (!eval { utime 0, 0, $pvbm }, 'utime(PVBM) fails');
+ ok (!eval { utime 0, 0, \$pvbm }, 'utime(PVBM ref) fails');
+
+ ok (!eval { <$pvbm> }, '<PVBM> fails');
+ ok (!eval { readline $pvbm }, 'readline(PVBM) fails');
+ ok (!eval { readline \$pvbm }, 'readline(PVBM ref) fails');
+
+ ok (!eval { open $pvbm, '<', 'none.such' }, 'open(PVBM) fails');
+ ok (!eval { open \$pvbm, '<', 'none.such', }, 'open(PVBM ref) fails');
+}