X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F28-uvar.t;h=364c7cddb73bcf746334601985cbd2b20fb53d21;hb=56d08a38a664736a762edf46817a346482c4004f;hp=b6c8959605c8c2173adbaa1c622369f61d3234c7;hpb=763ba8093427f3668368fa885741618ac6289d41;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/28-uvar.t b/t/28-uvar.t index b6c8959..364c7cd 100644 --- a/t/28-uvar.t +++ b/t/28-uvar.t @@ -8,7 +8,7 @@ use Test::More; use Variable::Magic qw/wizard cast dispell VMG_UVAR/; if (VMG_UVAR) { - plan tests => 16; + plan tests => 20; } else { plan skip_all => 'No nice uvar magic for this perl'; } @@ -29,7 +29,6 @@ ok(check(), 'uvar : create wizard'); my %h = (a => 1, b => 2, c => 3); my $res = cast %h, $wiz; - ok($res, 'uvar : cast succeeded'); ok(check(), 'uvar : cast didn\'t triggered the callback'); @@ -67,3 +66,20 @@ $x = delete $h{z}; ok(check(), 'uvar : delete non-existing key'); ok(!defined $x, 'uvar : delete non-existing key correctly'); +my $wiz2 = wizard 'fetch' => sub { 0 }; +my %h2 = (a => 37, b => 2, c => 3); +cast %h2, $wiz2; + +eval { + local $SIG{__WARN__} = sub { die }; + $x = $h2{a}; +}; +ok(!$@, 'uvar : fetch with incomplete magic'); +ok($x == 37, 'uvar : fetch with incomplete magic correctly'); + +eval { + local $SIG{__WARN__} = sub { die }; + $h2{a} = 73; +}; +ok(!$@, 'uvar : store with incomplete magic'); +ok($h2{a} == 73, 'uvar : store with incomplete magic correctly');