]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/28-uvar.t
Don't assign results in check blocks
[perl/modules/Variable-Magic.git] / t / 28-uvar.t
index 30d7f525e20b5d4e9651d88759d3148bd4067af4..8333ca042cd48d88ece4598dd3ad04279d090585 100644 (file)
@@ -23,41 +23,39 @@ my %h = (a => 1, b => 2, c => 3);
 my $res = check { cast %h, $wiz } { }, 'cast';
 ok $res, 'uvar: cast succeeded';
 
-my $x;
-
-check { $x = $h{a} } { fetch => 1 }, 'fetch directly';
+my $x = check { $h{a} } { fetch => 1 }, 'fetch directly';
 is $x, 1, 'uvar: fetch directly correctly';
 
-check { $x = "$h{b}" } { fetch => 1 }, 'fetch by interpolation';
+$x = check { "$h{b}" } { fetch => 1 }, 'fetch by interpolation';
 is $x, 2, 'uvar: fetch by interpolation correctly';
 
 check { $h{c} = 4 } { store => 1 }, 'store directly';
 
-check { $x = $h{c} = 5 } { store => 1 }, 'fetch and store';
+$x = check { $h{c} = 5 } { store => 1 }, 'fetch and store';
 is $x, 5, 'uvar: fetch and store correctly';
 
-check { $x = exists $h{c} } { exists => 1 }, 'exists';
+$x = check { exists $h{c} } { exists => 1 }, 'exists';
 ok $x, 'uvar: exists correctly';
 
-check { $x = delete $h{c} } { delete => 1 }, 'delete existing key';
+$x = check { delete $h{c} } { delete => 1 }, 'delete existing key';
 is $x, 5, 'uvar: delete existing key correctly';
 
-check { $x = delete $h{z} } { delete => 1 }, 'delete non-existing key';
+$x = check { delete $h{z} } { delete => 1 }, 'delete non-existing key';
 ok !defined $x, 'uvar: delete non-existing key correctly';
 
 my $wiz2 = wizard get => sub { 0 };
 cast %h, $wiz2;
 
-check { $x = $h{a} } { fetch => 1 }, 'fetch directly with also non uvar magic';
+$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';
 
 $wiz2 = wizard fetch => sub { 0 };
 my %h2 = (a => 37, b => 2, c => 3);
 cast %h2, $wiz2;
 
-eval {
+$x = eval {
  local $SIG{__WARN__} = sub { die };
- $x = $h2{a};
+ $h2{a};
 };
 is $@, '', 'uvar: fetch with incomplete magic doesn\'t croak';
 is $x, 37, 'uvar: fetch with incomplete magic correctly';