This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0: (no announcement message available)
[perl5.git] / t / op.dbm
CommitLineData
a687059c
LW
1#!./perl
2
3# $Header: op.dbm,v 3.0 89/10/18 15:28:31 lwall Locked $
4
5if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h') {
6 print "1..0\n";
7 exit;
8}
9
10print "1..9\n";
11
12unlink 'Op.dbmx.dir', 'Op.dbmx.pag';
13umask(0);
14print (dbmopen(h,'Op.dbmx',0640) ? "ok 1\n" : "not ok 1\n");
15($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
16 $blksize,$blocks) = stat('Op.dbmx.pag');
17print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
18while (($key,$value) = each(h)) {
19 $i++;
20}
21print (!$i ? "ok 3\n" : "not ok 3\n");
22
23$h{'goner1'} = 'snork';
24
25$h{'abc'} = 'ABC';
26$h{'def'} = 'DEF';
27$h{'jkl','mno'} = "JKL\034MNO";
28$h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
29$h{'a'} = 'A';
30$h{'b'} = 'B';
31$h{'c'} = 'C';
32$h{'d'} = 'D';
33$h{'e'} = 'E';
34$h{'f'} = 'F';
35$h{'g'} = 'G';
36$h{'h'} = 'H';
37$h{'i'} = 'I';
38
39$h{'goner2'} = 'snork';
40delete $h{'goner2'};
41
42dbmclose(h);
43print (dbmopen(h,'Op.dbmx',0640) ? "ok 4\n" : "not ok 4\n");
44
45$h{'j'} = 'J';
46$h{'k'} = 'K';
47$h{'l'} = 'L';
48$h{'m'} = 'M';
49$h{'n'} = 'N';
50$h{'o'} = 'O';
51$h{'p'} = 'P';
52$h{'q'} = 'Q';
53$h{'r'} = 'R';
54$h{'s'} = 'S';
55$h{'t'} = 'T';
56$h{'u'} = 'U';
57$h{'v'} = 'V';
58$h{'w'} = 'W';
59$h{'x'} = 'X';
60$h{'y'} = 'Y';
61$h{'z'} = 'Z';
62
63$h{'goner3'} = 'snork';
64
65delete $h{'goner1'};
66delete $h{'goner3'};
67
68@keys = keys(%h);
69@values = values(%h);
70
71if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
72
73while (($key,$value) = each(h)) {
74 if ($key eq $keys[$i] && $value eq $values[$i] && $key gt $value) {
75 $key =~ y/a-z/A-Z/;
76 $i++ if $key eq $value;
77 }
78}
79
80if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
81
82@keys = ('blurfl', keys(h), 'dyick');
83if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
84
85# check cache overflow and numeric keys and contents
86$ok = 1;
87for ($i = 1; $i < 200; $i++) { $h{$i + 0} = $i + 0; }
88for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; }
89print ($ok ? "ok 8\n" : "not ok 8\n");
90
91($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
92 $blksize,$blocks) = stat('Op.dbmx.pag');
93print ($size > 0 ? "ok 9\n" : "not ok 9\n");
94
95unlink 'Op.dbmx.dir', 'Op.dbmx.pag';