3 # $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $
7 unshift @INC, '../lib';
8 require Config; import Config;
9 if (($Config{'extensions'} !~ /\b(DB|[A-Z]DBM)_File\b/) ){
10 print "1..0 # Skipping (no DB_File or [A-Z]DBM_File)\n";
19 $Is_Dosish = ($^O eq 'amigaos' || $^O eq 'MSWin32' or $^O eq 'dos' or
20 $^O eq 'os2' or $^O eq 'mint');
25 print (tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR|O_CREAT, 0640)
26 ? "ok 1\n" : "not ok 1\n");
28 $Dfile = "Op_dbmx.pag";
30 ($Dfile) = <Op_dbmx*>;
33 print "ok 2 # Skipped: different file permission semantics\n";
36 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
37 $blksize,$blocks) = stat($Dfile);
38 print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
40 while (($key,$value) = each(%h)) {
43 print (!$i ? "ok 3\n" : "not ok 3 # i=$i\n\n");
45 $h{'goner1'} = 'snork';
49 $h{'jkl','mno'} = "JKL\034MNO";
50 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
61 $h{'goner2'} = 'snork';
65 print (tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR, 0640) ? "ok 4\n" : "not ok 4\n");
85 $h{'goner3'} = 'snork';
93 if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
95 while (($key,$value) = each(%h)) {
96 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
98 $i++ if $key eq $value;
102 if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
104 @keys = ('blurfl', keys(%h), 'dyick');
105 if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
110 # check cache overflow and numeric keys and contents
112 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
113 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
114 print ($ok ? "ok 8\n" : "not ok 8\n");
116 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
117 $blksize,$blocks) = stat($Dfile);
118 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
120 @h{0..200} = 200..400;
122 print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n";
124 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
125 if ($h{''} eq 'bar') {
129 if ($AnyDBM_File::ISA[0] eq 'DB_File' && $DB_File::db_ver >= 2.004010) {
130 ($major, $minor, $patch) = ($DB_File::db_ver =~ /^(\d+)\.(\d\d\d)(\d\d\d)/) ;
134 $compact = "$major.$minor.$patch" ;
136 # anydbm.t test 12 will fail when AnyDBM_File uses the combination of
137 # DB_File and Berkeley DB 2.4.10 (or greater).
138 # You are using DB_File $DB_File::VERSION and Berkeley DB $compact
140 # Berkeley DB 2 from version 2.4.10 onwards does not allow null keys.
141 # This feature will be reenabled in a future version of Berkeley DB.
143 print "ok 12 # skipped: db v$compact, no null key support\n" ;
146 print "not ok 12\n" ;
152 unlink 'Op_dbmx.sdbm_dir', $Dfile;
154 unlink 'Op_dbmx.dir', $Dfile;