6 require Config; import Config;
7 require Test::More; import Test::More;
15 $Is_Dosish = ($^O eq 'amigaos' || $^O eq 'MSWin32' ||
16 $^O eq 'NetWare' || $^O eq 'dos' ||
17 $^O eq 'os2' || $^O eq 'mint' ||
24 ok( tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR|O_CREAT, 0640), "Tie");
26 $Dfile = "Op_dbmx.pag";
28 ($Dfile) = <Op_dbmx*>;
33 skip( "different file permission semantics",1)
34 if ($Is_Dosish || $^O eq 'MacOS') ;
35 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
36 $blksize,$blocks) = stat($Dfile);
37 ok(($mode & 0777) == ($^O eq 'vos' ? 0750 : 0640) , "File permissions");
40 while (($key,$value) = each(%h)) {
44 ok(!$i,"Hash created empty");
46 $h{'goner1'} = 'snork';
50 $h{'jkl','mno'} = "JKL\034MNO";
51 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
62 $h{'goner2'} = 'snork';
66 ok(tie(%h,AnyDBM_File,'Op_dbmx', O_RDWR, 0640),"Re-tie hash");
86 $h{'goner3'} = 'snork';
94 ok( ($#keys == 29 && $#values == 29),'$#keys == $#values');
96 while (($key,$value) = each(%h)) {
97 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
99 $i++ if $key eq $value;
103 ok($i == 30,"keys and values match");
105 @keys = ('blurfl', keys(%h), 'dyick');
106 ok($#keys == 31,"Correct number of keys");
111 # check cache overflow and numeric keys and contents
113 for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
114 for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
115 ok($ok, "cache overflow and numeric keys and contents");
117 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
118 $blksize,$blocks) = stat($Dfile);
119 ok($size > 0, "check file size");
121 @h{0..200} = 200..400;
123 ok( join(':',200..400) eq join(':',@foo), "hash slice");
125 ok($h{'foo'} eq '', "empty value");
129 if ($AnyDBM_File::ISA[0] eq 'DB_File' && ($DB_File::db_ver >= 2.004010 && $DB_File::db_ver < 3.001)) {
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 returned with version 3.1
147 skip( "db v$compact, no null key support", 1) if $compact;
148 ok($h{''} eq 'bar','null key');
154 unlink 'Op_dbmx.sdbm_dir', $Dfile;
156 unlink 'Op_dbmx.dir', $Dfile;