X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F28-uvar.t;h=8601a9c1daa8881e93acfa99aecea8440043972b;hb=ed1f29a02e9894bb90bb4f3f3d42d7fe0fd3e545;hp=8333ca042cd48d88ece4598dd3ad04279d090585;hpb=c78c1790ebe43372ca405385d4cc053121b53ba0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/28-uvar.t b/t/28-uvar.t index 8333ca0..8601a9c 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 => 2 * 10 + 8 + 14 + 1; + plan tests => 2 * 15 + 12 + 14 + 1; } else { plan skip_all => 'No nice uvar magic for this perl'; } @@ -49,6 +49,29 @@ cast %h, $wiz2; $x = check { $h{a} } { fetch => 1 }, 'fetch directly with also non uvar magic'; is $x, 1, 'uvar: fetch directly with also non uvar magic correctly'; +SKIP: { + eval "use Tie::Hash"; + skip 'Tie::Hash required to test uvar magic on tied hashes' => 2 * 5 + 4 if $@; + diag "Using Tie::Hash $Tie::Hash::VERSION" if defined $Tie::Hash::VERSION; + + tie my %h, 'Tie::StdHash'; + %h = (x => 7, y => 8); + + $res = check { cast %h, $wiz } { }, 'cast on tied hash'; + ok $res, 'uvar: cast on tied hash succeeded'; + + $x = check { $h{x} } { fetch => 1 }, 'fetch on tied hash'; + is $x, 7, 'uvar: fetch on tied hash succeeded'; + + check { $h{x} = 9 } { store => 1 }, 'store on tied hash'; + + $x = check { exists $h{x} } { exists => 1 }, 'exists on tied hash'; + ok $x, 'uvar: exists on tied hash succeeded'; + + $x = check { delete $h{x} } { delete => 1 }, 'delete on tied hash'; + is $x, 9, 'uvar: delete on tied hash succeeded'; +} + $wiz2 = wizard fetch => sub { 0 }; my %h2 = (a => 37, b => 2, c => 3); cast %h2, $wiz2;