diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-03-03 17:48:31 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-03-03 17:48:31 +0000 |
commit | 10c8fecdc2f0a2ef9c548abff5961fa25cd83eca (patch) | |
tree | 750e204e55ff0008040249f2114df3d38df43fcf /t/op/avhv.t | |
parent | 49cb0e56d106a6666efa8660569a458b7eb3368b (diff) | |
download | perl-10c8fecdc2f0a2ef9c548abff5961fa25cd83eca.tar.gz |
support for list assignment to pseudohashes (from John Tobey
<jtobey@john-edwin-tobey.org>)
p4raw-id: //depot/perl@5492
Diffstat (limited to 't/op/avhv.t')
-rwxr-xr-x | t/op/avhv.t | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/t/op/avhv.t b/t/op/avhv.t index 23f9c69c8c..cd7c957619 100755 --- a/t/op/avhv.t +++ b/t/op/avhv.t @@ -1,5 +1,5 @@ #!./perl - + BEGIN { chdir 't' if -d 't'; unshift @INC, '../lib'; @@ -17,7 +17,7 @@ sub STORESIZE { $#{$_[0]} = $_[1]+1 } package main; -print "1..20\n"; +print "1..28\n"; $sch = { 'abc' => 1, @@ -139,3 +139,40 @@ print "ok 19\n"; print "not " unless "$avhv->{bar}" eq "yyy"; print "ok 20\n"; + +# hash assignment +%$avhv = (); +print "not " unless ref($avhv->[0]) eq 'HASH'; +print "ok 21\n"; + +%hv = %$avhv; +print "not " if grep defined, values %hv; +print "ok 22\n"; +print "not " if grep ref, keys %hv; +print "ok 23\n"; + +%$avhv = (foo => 29, pants => 2, bar => 0); +print "not " unless "@$avhv[1..3]" eq '29 0 2'; +print "ok 24\n"; + +my $extra; +my @extra; +($extra, %$avhv) = ("moo", foo => 42, pants => 53, bar => "HIKE!"); +print "not " unless "@$avhv[1..3]" eq '42 HIKE! 53' and $extra eq 'moo'; +print "ok 25\n"; + +%$avhv = (); +(%$avhv, $extra) = (foo => 42, pants => 53, bar => "HIKE!"); +print "not " unless "@$avhv[1..3]" eq '42 HIKE! 53' and !defined $extra; +print "ok 26\n"; + +@extra = qw(whatever and stuff); +%$avhv = (); +(%$avhv, @extra) = (foo => 42, pants => 53, bar => "HIKE!"); +print "not " unless "@$avhv[1..3]" eq '42 HIKE! 53' and @extra == 0; +print "ok 27\n"; + +%$avhv = (); +(@extra, %$avhv) = (foo => 42, pants => 53, bar => "HIKE!"); +print "not " unless ref $avhv->[0] eq 'HASH' and @extra == 6; +print "ok 28\n"; |