Commit | Line | Data |
---|---|---|
378cc40b LW |
1 | #!./perl |
2 | ||
79072805 | 3 | # $RCSfile: delete.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:44 $ |
378cc40b | 4 | |
5f05dabc | 5 | print "1..16\n"; |
378cc40b LW |
6 | |
7 | $foo{1} = 'a'; | |
8 | $foo{2} = 'b'; | |
9 | $foo{3} = 'c'; | |
5f05dabc | 10 | $foo{4} = 'd'; |
11 | $foo{5} = 'e'; | |
378cc40b LW |
12 | |
13 | $foo = delete $foo{2}; | |
14 | ||
a687059c LW |
15 | if ($foo eq 'b') {print "ok 1\n";} else {print "not ok 1 $foo\n";} |
16 | if ($foo{2} eq '') {print "ok 2\n";} else {print "not ok 2 $foo{2}\n";} | |
378cc40b LW |
17 | if ($foo{1} eq 'a') {print "ok 3\n";} else {print "not ok 3\n";} |
18 | if ($foo{3} eq 'c') {print "ok 4\n";} else {print "not ok 4\n";} | |
5f05dabc | 19 | if ($foo{4} eq 'd') {print "ok 5\n";} else {print "not ok 5\n";} |
20 | if ($foo{5} eq 'e') {print "ok 6\n";} else {print "not ok 6\n";} | |
21 | ||
22 | @foo = delete @foo{4, 5}; | |
23 | ||
24 | if (@foo == 2) {print "ok 7\n";} else {print "not ok 7 ", @foo+0, "\n";} | |
25 | if ($foo[0] eq 'd') {print "ok 8\n";} else {print "not ok 8 ", $foo[0], "\n";} | |
26 | if ($foo[1] eq 'e') {print "ok 9\n";} else {print "not ok 9 ", $foo[1], "\n";} | |
27 | if ($foo{4} eq '') {print "ok 10\n";} else {print "not ok 10 $foo{4}\n";} | |
28 | if ($foo{5} eq '') {print "ok 11\n";} else {print "not ok 11 $foo{5}\n";} | |
29 | if ($foo{1} eq 'a') {print "ok 12\n";} else {print "not ok 12\n";} | |
30 | if ($foo{3} eq 'c') {print "ok 13\n";} else {print "not ok 13\n";} | |
378cc40b | 31 | |
c6aa4a32 | 32 | $foo = join('',values(%foo)); |
5f05dabc | 33 | if ($foo eq 'ac' || $foo eq 'ca') {print "ok 14\n";} else {print "not ok 14\n";} |
378cc40b | 34 | |
c6aa4a32 | 35 | foreach $key (keys %foo) { |
378cc40b LW |
36 | delete $foo{$key}; |
37 | } | |
38 | ||
39 | $foo{'foo'} = 'x'; | |
40 | $foo{'bar'} = 'y'; | |
41 | ||
c6aa4a32 | 42 | $foo = join('',values(%foo)); |
5f05dabc | 43 | print +($foo eq 'xy' || $foo eq 'yx') ? "ok 15\n" : "not ok 15\n"; |
a0d0e21e LW |
44 | |
45 | $refhash{"top"}->{"foo"} = "FOO"; | |
46 | $refhash{"top"}->{"bar"} = "BAR"; | |
47 | ||
48 | delete $refhash{"top"}->{"bar"}; | |
49 | @list = keys %{$refhash{"top"}}; | |
50 | ||
5f05dabc | 51 | print "@list" eq "foo" ? "ok 16\n" : "not ok 16 @list\n"; |