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