]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/32-hash.t
Test 'delete' uvar magic and introduce VMG_COMPAT_HASH_DELETE_NOUVAR_VOID
[perl/modules/Variable-Magic.git] / t / 32-hash.t
index 8ae273e73037b3171dd35de0b4b5b5749e29519b..703bcd3df82b5f4c30e1b7495fc24accfe5f1d46 100644 (file)
@@ -3,9 +3,13 @@
 use strict;
 use warnings;
 
-use Test::More tests => (2 * 24 + 7) + (2 * 5 + 5) + 1;
+use Test::More tests => (2 * 27 + 9) + (2 * 5 + 5) + 1;
 
-use Variable::Magic qw<cast dispell VMG_UVAR>;
+use Variable::Magic qw<
+ cast dispell
+ VMG_UVAR
+ VMG_COMPAT_HASH_DELETE_NOUVAR_VOID
+>;
 
 use lib 't/lib';
 use Variable::Magic::TestWatcher;
@@ -43,6 +47,21 @@ for (1 .. 2) {
  ok $s, "hash: exists correctly ($_)";
 }
 
+# delete
+
+watch { delete $h{bar} } +{
+ ((delete => 1) x !VMG_COMPAT_HASH_DELETE_NOUVAR_VOID, copy => 1) x VMG_UVAR
+}, 'delete in void context';
+
+for (1 .. 2) {
+ $s = watch { delete $h{baz} } +{ (delete => 1, copy => 1) x VMG_UVAR },
+                                                "delete in scalar context ($_)";
+ my $exp = $_ == 1 ? $n{baz} : undef;
+ is $s, $exp, "hash: delete correctly ($_)";
+}
+
+# clear
+
 watch { %h = () } { clear => 1 }, 'empty in list context';
 
 watch { $h{a} = -1; %h = (b => $h{a}) }