3 # $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $
8 require Config; import Config;
9 if ($Config{'extensions'} !~ /\bODBM_File\b/) {
16 #If Fcntl is not available, try 0x202 or 0x102 for O_RDWR|O_CREAT
24 print (tie(%h,ODBM_File,'Op.dbmx', O_RDWR|O_CREAT, 0640) ? "ok 1\n" : "not ok 1\n");
26 $Dfile = "Op.dbmx.pag";
28 ($Dfile) = <Op.dbmx*>;
30 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
31 $blksize,$blocks) = stat($Dfile);
32 print (($mode & 0777) == ($^O eq 'os2' ? 0666 : 0640) || $^O eq 'amigaos'
33 ? "ok 2\n" : "not ok 2\n");
34 while (($key,$value) = each(%h)) {
37 print (!$i ? "ok 3\n" : "not ok 3\n");
39 $h{'goner1'} = 'snork';
43 $h{'jkl','mno'} = "JKL\034MNO";
44 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
55 $h{'goner2'} = 'snork';
59 print (tie(%h,ODBM_File,'Op.dbmx', O_RDWR, 0640) ? "ok 4\n" : "not ok 4\n");
79 $h{'goner3'} = 'snork';
87 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
89 while (($key,$value) = each(h)) {
90 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
92 $i++ if $key eq $value;
96 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
98 @keys = ('blurfl', keys(h), 'dyick');
99 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
104 # check cache overflow and numeric keys and contents
106 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
107 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
108 print ($ok ? "ok 8\n" : "not ok 8\n");
110 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
111 $blksize,$blocks) = stat($Dfile);
112 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
114 @h{0..200} = 200..400;
116 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
118 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
119 print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
122 unlink 'Op.dbmx.dir', $Dfile;