3 # $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $
7 unshift @INC, '../lib';
10 #If Fcntl is not available, try 0x202 or 0x102 for O_RDWR|O_CREAT
15 $Is_Dosish = ($^O eq 'amigaos' || $^O eq 'MSWin32' or $^O eq 'dos' or
16 $^O eq 'os2' or $^O eq 'mint');
21 print (tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR|O_CREAT, 0640)
22 ? "ok 1\n" : "not ok 1\n");
24 $Dfile = "Op_dbmx.pag";
26 ($Dfile) = <Op_dbmx*>;
29 print "ok 2 # Skipped: different file permission semantics\n";
32 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
33 $blksize,$blocks) = stat($Dfile);
34 print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
36 while (($key,$value) = each(%h)) {
39 print (!$i ? "ok 3\n" : "not ok 3 # i=$i\n\n");
41 $h{'goner1'} = 'snork';
45 $h{'jkl','mno'} = "JKL\034MNO";
46 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
57 $h{'goner2'} = 'snork';
61 print (tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR, 0640) ? "ok 4\n" : "not ok 4\n");
81 $h{'goner3'} = 'snork';
89 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
91 while (($key,$value) = each(%h)) {
92 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
94 $i++ if $key eq $value;
98 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
100 @keys = ('blurfl', keys(%h), 'dyick');
101 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
106 # check cache overflow and numeric keys and contents
108 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
109 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
110 print ($ok ? "ok 8\n" : "not ok 8\n");
112 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
113 $blksize,$blocks) = stat($Dfile);
114 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
116 @h{0..200} = 200..400;
118 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
120 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
121 if ($h{''} eq 'bar') {
125 if ($AnyDBM_File::ISA[0] eq 'DB_File' && $DB_File::db_ver >= 2.004010) {
126 ($major, $minor, $patch) = ($DB_File::db_ver =~ /^(\d+)\.(\d\d\d)(\d\d\d)/) ;
130 $compact = "$major.$minor.$patch" ;
132 # anydbm.t test 12 will fail when AnyDBM_File uses the combination of
133 # DB_File and Berkeley DB 2.4.10 (or greater).
134 # You are using DB_File $DB_File::VERSION and Berkeley DB $compact
136 # Berkeley DB 2 from version 2.4.10 onwards does not allow null keys.
137 # This feature will be reenabled in a future version of Berkeley DB.
139 print "ok 12 # skipped: db v$compact, no null key support\n" ;
142 print "not ok 12\n" ;
148 unlink 'Op_dbmx.sdbm_dir', $Dfile;
150 unlink 'Op_dbmx.dir', $Dfile;