summaryrefslogtreecommitdiff
path: root/ext/XS/APItest/t/hash.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-09-19 10:53:01 +0000
committerNicholas Clark <nick@ccl4.org>2007-09-19 10:53:01 +0000
commit55289a74a75e6b09fb47c096d0658212f035d6bf (patch)
treeab21251a689519bb277719e264a10da9bd0c8b6b /ext/XS/APItest/t/hash.t
parent80d693dde7675a7adf00a63b6fe47d20f709d2c1 (diff)
downloadperl-55289a74a75e6b09fb47c096d0658212f035d6bf.tar.gz
Call the key transformation function for hv_delete().
Honour the HV_DISABLE_UVAR_XKEY for hv_delete(). Test this. [Pass in 3 more parameters to S_hv_magic_uvar_xkey()] p4raw-id: //depot/perl@31905
Diffstat (limited to 'ext/XS/APItest/t/hash.t')
-rw-r--r--ext/XS/APItest/t/hash.t32
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/XS/APItest/t/hash.t b/ext/XS/APItest/t/hash.t
index 4af7f88ad6..949f175e0a 100644
--- a/ext/XS/APItest/t/hash.t
+++ b/ext/XS/APItest/t/hash.t
@@ -18,7 +18,7 @@ use utf8;
use Tie::Hash;
use Test::More 'no_plan';
-use_ok('XS::APItest');
+BEGIN {use_ok('XS::APItest')};
sub preform_test;
sub test_present;
@@ -95,7 +95,7 @@ foreach my $in ("", "N", "a\0b") {
is ($got, $in, "test_share_unshare_pvn");
}
-{
+if ($] > 5.009) {
my %hash;
XS::APItest::Hash::rot13_hash(\%hash);
$hash{a}++; @hash{qw(p i e)} = (2, 4, 8);
@@ -105,6 +105,34 @@ foreach my $in ("", "N", "a\0b") {
"uvar magic called exactly once on store");
is($hash{i}, 4);
+
+ is(delete $hash{a}, 1);
+
+ is(keys %hash, 3);
+ @keys = sort keys %hash;
+ is("@keys", join(' ', sort(rot13(qw(p i e)))));
+
+ is (XS::APItest::Hash::delete_ent (\%hash, 'p',
+ XS::APItest::HV_DISABLE_UVAR_XKEY),
+ undef, "Deleting a known key with conversion disabled fails (ent)");
+ is(keys %hash, 3);
+
+ is (XS::APItest::Hash::delete_ent (\%hash, 'p', 0),
+ 2, "Deleting a known key with conversion enabled works (ent)");
+ is(keys %hash, 2);
+ @keys = sort keys %hash;
+ is("@keys", join(' ', sort(rot13(qw(i e)))));
+
+ is (XS::APItest::Hash::delete (\%hash, 'i',
+ XS::APItest::HV_DISABLE_UVAR_XKEY),
+ undef, "Deleting a known key with conversion disabled fails");
+ is(keys %hash, 2);
+
+ is (XS::APItest::Hash::delete (\%hash, 'i', 0),
+ 4, "Deleting a known key with conversion enabled works");
+ is(keys %hash, 1);
+ @keys = sort keys %hash;
+ is("@keys", join(' ', sort(rot13(qw(e)))));
}
exit;