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.delete
CommitLineData
378cc40b
LW
1#!./perl
2
a687059c 3# $Header: op.delete,v 3.0 89/10/18 15:28:36 lwall Locked $
378cc40b
LW
4
5print "1..6\n";
6
7$foo{1} = 'a';
8$foo{2} = 'b';
9$foo{3} = 'c';
10
11$foo = delete $foo{2};
12
a687059c
LW
13if ($foo eq 'b') {print "ok 1\n";} else {print "not ok 1 $foo\n";}
14if ($foo{2} eq '') {print "ok 2\n";} else {print "not ok 2 $foo{2}\n";}
378cc40b
LW
15if ($foo{1} eq 'a') {print "ok 3\n";} else {print "not ok 3\n";}
16if ($foo{3} eq 'c') {print "ok 4\n";} else {print "not ok 4\n";}
17
18$foo = join('',values(foo));
19if ($foo eq 'ac' || $foo eq 'ca') {print "ok 5\n";} else {print "not ok 5\n";}
20
a687059c 21foreach $key (keys foo) {
378cc40b
LW
22 delete $foo{$key};
23}
24
25$foo{'foo'} = 'x';
26$foo{'bar'} = 'y';
27
28$foo = join('',values(foo));
29if ($foo eq 'xy' || $foo eq 'yx') {print "ok 6\n";} else {print "not ok 6\n";}