X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F33-code.t;h=a2812e3d2e0224fde8c63838a88b45ccd1a4dad3;hb=da422089a9a5dfbf84e72ec3ba867063471ff41c;hp=4fc4e35b9daf9284a527dd9c7c6c5d208ba5c357;hpb=505fda7126b01811c0ca990552876a1c6d9dc7c3;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/33-code.t b/t/33-code.t index 4fc4e35..a2812e3 100644 --- a/t/33-code.t +++ b/t/33-code.t @@ -10,49 +10,49 @@ use Variable::Magic qw/cast dispell/; use lib 't/lib'; use Variable::Magic::TestWatcher; -my $wiz = init +my $wiz = init_watcher [ qw/get set len clear free copy dup local fetch store exists delete/ ], 'code'; my $x = 0; sub hlagh { ++$x }; -check { cast &hlagh, $wiz } { }, 'cast'; +watch { cast &hlagh, $wiz } { }, 'cast'; is $x, 0, 'code: cast didn\'t called code'; -check { hlagh() } { }, 'call without arguments'; +watch { hlagh() } { }, 'call without arguments'; is $x, 1, 'code: call without arguments succeeded'; -check { hlagh(1, 2, 3) } { }, 'call with arguments'; +watch { hlagh(1, 2, 3) } { }, 'call with arguments'; is $x, 2, 'code: call with arguments succeeded'; -check { undef *hlagh } { free => 1 }, 'undef symbol table entry'; +watch { undef *hlagh } { free => 1 }, 'undef symbol table entry'; is $x, 2, 'code: undef symbol table entry didn\'t call code'; my $y = 0; -check { *hlagh = sub { ++$y } } { }, 'redefining sub'; +watch { *hlagh = sub { ++$y } } { }, 'redefining sub'; -check { cast &hlagh, $wiz } { }, 're-cast'; +watch { cast &hlagh, $wiz } { }, 're-cast'; is $y, 0, 'code: re-cast didn\'t called code'; -my ($r) = check { \&hlagh } { }, 'reference'; +my ($r) = watch { \&hlagh } { }, 'reference'; is $y, 0, 'code: reference didn\'t called code'; -check { $r->() } { }, 'call reference'; +watch { $r->() } { }, 'call reference'; is $y, 1, 'code: call reference succeeded'; is $x, 2, 'code: call reference didn\'t called the previous code'; my $z = 0; -check { +watch { no warnings 'redefine'; *hlagh = sub { ++$z } } { }, 'redefining sub 2'; -check { hlagh() } { }, 'call without arguments 2'; +watch { hlagh() } { }, 'call without arguments 2'; is $z, 1, 'code: call without arguments 2 succeeded'; is $y, 1, 'code: call without arguments 2 didn\'t called the previous code'; -check { dispell &hlagh, $wiz } { }, 'dispell'; +watch { dispell &hlagh, $wiz } { }, 'dispell'; is $z, 1, 'code: dispell didn\'t called code'; $Variable::Magic::TestWatcher::mg_end = { free => 1 };