summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-03-24 10:29:37 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-03-24 10:29:37 +0000
commitf6c77cf1bf4d7cb2c7a64dd7608120b471f84062 (patch)
treef451c26b5e8e83030868fb6a14844822e66dfc8e /t
parente3f3bf95bcb81efe35cb0f0d3e3528d5c002dcec (diff)
downloadperl-f6c77cf1bf4d7cb2c7a64dd7608120b471f84062.tar.gz
Implement:
1. open($fh,"+<",undef); # add test to t/io/open.t 2. open($fh,"+<",\$var); # New test t/lib/io_scalar.t p4raw-id: //depot/perlio@9318
Diffstat (limited to 't')
-rwxr-xr-xt/io/open.t17
-rwxr-xr-xt/io/utf8.t7
-rw-r--r--t/lib/io_scalar.t35
3 files changed, 54 insertions, 5 deletions
diff --git a/t/io/open.t b/t/io/open.t
index 635ea4c364..9b37db390c 100755
--- a/t/io/open.t
+++ b/t/io/open.t
@@ -11,7 +11,7 @@ use warnings;
$Is_VMS = $^O eq 'VMS';
$Is_Dos = $^O eq 'dos';
-print "1..66\n";
+print "1..70\n";
my $test = 1;
@@ -289,3 +289,18 @@ ok;
}
ok;
}
+
+# 67..70 - magic temporary file via 3 arg open with undef
+{
+ open(my $x,"+<",undef) or print "not ";
+ ok;
+ print "not " unless defined(fileno($x));
+ ok;
+ select $x;
+ ok; # goes to $x
+ select STDOUT;
+ seek($x,0,0);
+ print <$x>;
+ print "not " unless tell($x) > 3;
+ ok;
+}
diff --git a/t/io/utf8.t b/t/io/utf8.t
index d0201aaffb..07e626f085 100755
--- a/t/io/utf8.t
+++ b/t/io/utf8.t
@@ -3,8 +3,7 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
- require Config; import Config;
- unless ($Config{'useperlio'}) {
+ unless (defined &perlio::import) {
print "1..0 # Skip: not perlio\n";
exit 0;
}
@@ -79,7 +78,7 @@ open F, ">:utf8", 'a' or die $!;
binmode(F); # we write a "\n" and then tell() - avoid CRLF issues.
print F $a;
my $y;
-{ my $x = tell(F);
+{ my $x = tell(F);
{ use bytes; $y = length($a);}
print "not " unless $x == $y;
print "ok 16\n";
@@ -99,7 +98,7 @@ print "not ($y) " unless $y == 1;
print "ok 18\n";
}
-{ my $x = tell(F);
+{ my $x = tell(F);
{ use bytes; $y += 3;}
print "not ($x,$y) " unless $x == $y;
print "ok 19\n";
diff --git a/t/lib/io_scalar.t b/t/lib/io_scalar.t
new file mode 100644
index 0000000000..569abd71e1
--- /dev/null
+++ b/t/lib/io_scalar.t
@@ -0,0 +1,35 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ unless (defined &perlio::import) {
+ print "1..0 # Skip: not perlio\n";
+ exit 0;
+ }
+}
+
+$| = 1;
+print "1..9\n";
+
+my $fh;
+my $var = "ok 2\n";
+open($fh,"+<",\$var) or print "not ";
+print "ok 1\n";
+print <$fh>;
+print "not " unless eof($fh);
+print "ok 3\n";
+seek($fh,0,0) or print "not ";
+print "not " if eof($fh);
+print "ok 4\n";
+print "ok 5\n";
+print $fh "ok 7\n" or print "not ";
+print "ok 6\n";
+print $var;
+$var = "foo\nbar\n";
+seek($fh,0,0) or print "not ";
+print "not " if eof($fh);
+print "ok 8\n";
+print "not " unless <$fh> eq "foo\n";
+print "ok 9\n";
+