X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=blobdiff_plain;f=t%2F16-huf.t;h=024a39c9bb32ad90c71d2e6d571213b3cb8c01e0;hp=08ca8d413a6a059122b9791ac140b898d677ea51;hb=93df7812b9a0da8cdfa57a107eb2f8f4b4744b49;hpb=ae7f6e2ea2193f2a2fd33dd76aa9cdfdb82a9743 diff --git a/t/16-huf.t b/t/16-huf.t index 08ca8d4..024a39c 100644 --- a/t/16-huf.t +++ b/t/16-huf.t @@ -5,25 +5,21 @@ use warnings; use Test::More; -use Variable::Magic qw/wizard cast dispell VMG_UVAR/; +use lib 't/lib'; +use VPIT::TestHelpers; -if (!VMG_UVAR) { - plan skip_all => 'No nice uvar magic for this perl'; -} +use Variable::Magic qw; -eval "use Hash::Util::FieldHash"; -if ($@) { - plan skip_all => 'Hash::Util::FieldHash required for testing uvar interaction'; -} else { +if (VMG_UVAR) { + load_or_skip_all('Hash::Util::FieldHash', undef, [ ]); plan tests => 2 * 5 + 7 + 1; - my $v = $Hash::Util::FieldHash::VERSION; - diag "Using Hash::Util::FieldHash $v" if defined $v; +} else { + skip_all 'No nice uvar magic for this perl'; } -use lib 't/lib'; use Variable::Magic::TestWatcher; -my $wiz = init [ qw/fetch store/ ], 'huf'; +my $wiz = init_watcher [ qw ], 'huf'; ok defined($wiz), 'huf: wizard with uvar is defined'; is ref($wiz), 'SCALAR', 'huf: wizard with uvar is a scalar ref'; @@ -33,16 +29,16 @@ my $obj = { }; bless $obj, 'Variable::Magic::Test::Mock'; $h{$obj} = 5; -my ($res) = check { cast %h, $wiz } { }, 'cast uvar magic on fieldhash'; +my ($res) = watch { cast %h, $wiz } { }, 'cast uvar magic on fieldhash'; ok $res, 'huf: cast uvar magic on fieldhash succeeded'; -my ($s) = check { $h{$obj} } { fetch => 1 }, 'fetch on magical fieldhash'; +my ($s) = watch { $h{$obj} } { fetch => 1 }, 'fetch on magical fieldhash'; is $s, 5, 'huf: fetch on magical fieldhash succeeded'; -check { $h{$obj} = 7 } { store => 1 }, 'store on magical fieldhash'; +watch { $h{$obj} = 7 } { store => 1 }, 'store on magical fieldhash'; is $h{$obj}, 7, 'huf: store on magical fieldhash succeeded'; -($res) = check { dispell %h, $wiz } { }, 'dispell uvar magic on fieldhash'; +($res) = watch { dispell %h, $wiz } { }, 'dispell uvar magic on fieldhash'; ok $res, 'huf: dispell uvar magic on fieldhash succeeded'; $h{$obj} = 11;