summaryrefslogtreecommitdiff
path: root/lib/Hash
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-04-14 23:54:43 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2002-04-15 13:47:16 +0000
commit0cd24ecfa77c796fc462e9808f747fde6a836a04 (patch)
tree6922addf14062706326011ee35138f48d5af9742 /lib/Hash
parentaae85cebe8a650adb00c18408359c5c63d5ee01e (diff)
downloadperl-0cd24ecfa77c796fc462e9808f747fde6a836a04.tar.gz
Re: [PATCH] Re: restricted hashes are unblessable
Message-ID: <20020414215442.GE301@Bagpuss.unfortu.net> p4raw-id: //depot/perl@15926
Diffstat (limited to 'lib/Hash')
-rw-r--r--lib/Hash/Util.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/Hash/Util.t b/lib/Hash/Util.t
index a42a52e03c..20efb443ef 100644
--- a/lib/Hash/Util.t
+++ b/lib/Hash/Util.t
@@ -6,7 +6,8 @@ BEGIN {
chdir 't';
}
}
-use Test::More tests => 55;
+use Test::More tests => 61;
+use strict;
my @Exported_Funcs;
BEGIN {
@@ -202,4 +203,27 @@ like( $@, qr/^Attempt to access disallowed key 'I_DONT_EXIST' in a restricted ha
is (scalar keys %hash, 0, "and therefore there are no keys");
$hash{second} = 1;
is (scalar keys %hash, 1, "we now have just one key");
+ delete $hash{second};
+ is (scalar keys %hash, 0, "back to zero");
+
+ unlock_keys(%hash); # We have deliberately left a placeholder.
+
+ $hash{void} = undef;
+ $hash{nowt} = undef;
+
+ is (scalar keys %hash, 2, "two keys, values both undef");
+
+ lock_keys(%hash);
+
+ is (scalar keys %hash, 2, "still two keys after locking");
+
+ eval {$hash{second} = -1};
+ like ($@,
+ qr/^Attempt to access disallowed key 'second' in a restricted hash/,
+ 'previously locked place holders should fail');
+
+ is ($hash{void}, undef,
+ "undef values should not be misunderstood as placeholders");
+ is ($hash{nowt}, undef,
+ "undef values should not be misunderstood as placeholders (again)");
}