3 # $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $
10 #If Fcntl is not available, try 0x202 or 0x102 for O_RDWR|O_CREAT
18 print (tie(%h,AnyDBM_File,'Op.dbmx', O_RDWR|O_CREAT, 0640) ? "ok 1\n" : "not ok 1\n");
20 $Dfile = "Op.dbmx.pag";
22 ($Dfile) = <Op.dbmx*>;
24 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
25 $blksize,$blocks) = stat($Dfile);
26 print (($mode & 0777) == ($^O eq 'os2' ? 0666 : 0640) || $^O eq 'amigaos'
27 ? "ok 2\n" : "not ok 2\n");
28 while (($key,$value) = each(%h)) {
31 print (!$i ? "ok 3\n" : "not ok 3\n");
33 $h{'goner1'} = 'snork';
37 $h{'jkl','mno'} = "JKL\034MNO";
38 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
49 $h{'goner2'} = 'snork';
53 print (tie(%h,AnyDBM_File,'Op.dbmx', O_RDWR, 0640) ? "ok 4\n" : "not ok 4\n");
73 $h{'goner3'} = 'snork';
81 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
83 while (($key,$value) = each(h)) {
84 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
86 $i++ if $key eq $value;
90 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
92 @keys = ('blurfl', keys(h), 'dyick');
93 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
98 # check cache overflow and numeric keys and contents
100 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
101 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
102 print ($ok ? "ok 8\n" : "not ok 8\n");
104 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
105 $blksize,$blocks) = stat($Dfile);
106 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
108 @h{0..200} = 200..400;
110 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
112 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
113 print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
116 unlink 'Op.dbmx.dir', $Dfile;