summaryrefslogtreecommitdiff
path: root/t/lib
diff options
context:
space:
mode:
Diffstat (limited to 't/lib')
-rwxr-xr-xt/lib/db-btree.t6
-rwxr-xr-xt/lib/db-recno.t68
-rwxr-xr-xt/lib/filehand.t50
-rwxr-xr-xt/lib/safe2.t3
4 files changed, 120 insertions, 7 deletions
diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t
index e20cfaba06..7dea2ed5ea 100755
--- a/t/lib/db-btree.t
+++ b/t/lib/db-btree.t
@@ -429,13 +429,13 @@ $Dfile1 = "btree1" ;
$Dfile2 = "btree2" ;
$Dfile3 = "btree3" ;
-$dbh1 = TIEHASH DB_File::BTREEINFO ;
+$dbh1 = new DB_File::BTREEINFO ;
$dbh1->{compare} = sub { $_[0] <=> $_[1] } ;
-$dbh2 = TIEHASH DB_File::BTREEINFO ;
+$dbh2 = new DB_File::BTREEINFO ;
$dbh2->{compare} = sub { $_[0] cmp $_[1] } ;
-$dbh3 = TIEHASH DB_File::BTREEINFO ;
+$dbh3 = new DB_File::BTREEINFO ;
$dbh3->{compare} = sub { length $_[0] <=> length $_[1] } ;
diff --git a/t/lib/db-recno.t b/t/lib/db-recno.t
index 9427a43838..6027b6fa95 100755
--- a/t/lib/db-recno.t
+++ b/t/lib/db-recno.t
@@ -23,7 +23,7 @@ sub ok
print "ok $no\n" ;
}
-print "1..47\n";
+print "1..55\n";
my $Dfile = "recno.tmp";
unlink $Dfile ;
@@ -179,4 +179,70 @@ untie(@h);
unlink $Dfile;
+{
+ # Check bval defaults to \n
+
+ my @h = () ;
+ my $dbh = new DB_File::RECNOINFO ;
+ ok(48, tie @h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $dbh ) ;
+ $h[0] = "abc" ;
+ $h[1] = "def" ;
+ $h[3] = "ghi" ;
+ untie @h ;
+ my $x = `cat $Dfile` ;
+ ok(49, $x eq "abc\ndef\n\nghi\n") ;
+ unlink $Dfile;
+}
+
+{
+ # Change bval
+
+ my @h = () ;
+ my $dbh = new DB_File::RECNOINFO ;
+ $dbh->{bval} = "-" ;
+ ok(50, tie @h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $dbh ) ;
+ $h[0] = "abc" ;
+ $h[1] = "def" ;
+ $h[3] = "ghi" ;
+ untie @h ;
+ my $x = `cat $Dfile` ;
+ ok(51, $x eq "abc-def--ghi-") ;
+ unlink $Dfile;
+}
+
+{
+ # Check R_FIXEDLEN with default bval (space)
+
+ my @h = () ;
+ my $dbh = new DB_File::RECNOINFO ;
+ $dbh->{flags} = R_FIXEDLEN ;
+ $dbh->{reclen} = 5 ;
+ ok(52, tie @h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $dbh ) ;
+ $h[0] = "abc" ;
+ $h[1] = "def" ;
+ $h[3] = "ghi" ;
+ untie @h ;
+ my $x = `cat $Dfile` ;
+ ok(53, $x eq "abc def ghi ") ;
+ unlink $Dfile;
+}
+
+{
+ # Check R_FIXEDLEN with user-defined bval
+
+ my @h = () ;
+ my $dbh = new DB_File::RECNOINFO ;
+ $dbh->{flags} = R_FIXEDLEN ;
+ $dbh->{bval} = "-" ;
+ $dbh->{reclen} = 5 ;
+ ok(54, tie @h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $dbh ) ;
+ $h[0] = "abc" ;
+ $h[1] = "def" ;
+ $h[3] = "ghi" ;
+ untie @h ;
+ my $x = `cat $Dfile` ;
+ ok(55, $x eq "abc--def-------ghi--") ;
+ unlink $Dfile;
+}
+
exit ;
diff --git a/t/lib/filehand.t b/t/lib/filehand.t
index 0199a52ace..038a73cdd7 100755
--- a/t/lib/filehand.t
+++ b/t/lib/filehand.t
@@ -4,7 +4,7 @@ BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; import Config;
- if ($Config{'extensions'} !~ /\bFileHandle\b/ && $^O ne 'VMS') {
+ if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
print "1..0\n";
exit 0;
}
@@ -13,17 +13,63 @@ BEGIN {
use FileHandle;
use strict subs;
+autoflush STDOUT 1;
+
$mystdout = new_from_fd FileHandle 1,"w";
$| = 1;
autoflush $mystdout;
-print "1..4\n";
+print "1..11\n";
print $mystdout "ok ",fileno($mystdout),"\n";
$fh = new FileHandle "TEST", O_RDONLY and print "ok 2\n";
+
+
$buffer = <$fh>;
print $buffer eq "#!./perl\n" ? "ok 3\n" : "not ok 3\n";
+
ungetc $fh 65;
CORE::read($fh, $buf,1);
print $buf eq 'A' ? "ok 4\n" : "not ok 4\n";
+
+close $fh;
+
+$fh = new FileHandle;
+
+print "not " unless ($fh->open("< TEST") && <$fh> eq $buffer);
+print "ok 5\n";
+
+$fh->seek(0,0);
+print "not " unless (<$fh> eq $buffer);
+print "ok 6\n";
+
+$fh->seek(0,2);
+$line = <$fh>;
+print "not " if (defined($line) || !$fh->eof);
+print "ok 7\n";
+
+print "not " unless ($fh->open("TEST","r") && !$fh->tell && $fh->close);
+print "ok 8\n";
+
+autoflush STDOUT 0;
+
+print "not " if ($|);
+print "ok 9\n";
+
+autoflush STDOUT 1;
+
+print "not " unless ($|);
+print "ok 10\n";
+
+($rd,$wr) = FileHandle::pipe;
+
+if (fork) {
+ $wr->close;
+ print $rd->getline;
+}
+else {
+ $rd->close;
+ $wr->printf("ok %d\n",11);
+ exit(0);
+}
diff --git a/t/lib/safe2.t b/t/lib/safe2.t
index 61c6c8ffec..586eace6a8 100755
--- a/t/lib/safe2.t
+++ b/t/lib/safe2.t
@@ -119,7 +119,8 @@ print $@ =~ /foo bar/ ? "ok 29\n" : "not ok 29\n";
my $t = 30;
$cpt->rdo('/non/existant/file.name');
-print +(($! =~ /No such file/ || $! =~ /file specification syntax error/) ?
+print +(($! =~ /No such file/ || $! =~ /file specification syntax error/) ||
+ $! =~ /A file or directory in the path name does not exist/ ?
"ok $t\n" : "not ok $t # $!\n"); $t++;
print 1 ? "ok $t\n" : "not ok $t\n#$@/$!\n"; $t++;