]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/20-get.t
Fix and test segfaults and wrong "Unknown error" exceptions when dieing in require...
[perl/modules/Variable-Magic.git] / t / 20-get.t
index 215b5df03b6bf44cc4a1baac1111f604a0b4e35b..02ef39bc62d2902e94bf0b2d67d9715eec5b448f 100644 (file)
@@ -1,23 +1,26 @@
 #!perl -T
 
-use Test::More tests => 6;
+use strict;
+use warnings;
 
-use Variable::Magic qw/wizard cast/;
+use Test::More tests => 2 * 4 + 2 + 1;
 
-my $c = 0;
-my $wiz = wizard get => sub { ++$c };
-ok($c == 0, 'get : create wizard');
+use Variable::Magic qw/cast/;
+
+use lib 't/lib';
+use Variable::Magic::TestWatcher;
+
+my $wiz = init 'get', 'get';
 
 my $n = int rand 1000;
 my $a = $n;
 
-cast $a, $wiz;
-ok($c == 0, 'get : cast');
+check { cast $a, $wiz } { }, 'cast';
 
-my $b = $a;
-ok($c == 1, 'get : assign to');
-ok($b == $n, 'get : assign to correctly');
+my $b;
+# $b has to be set inside the block for the test to pass on 5.8.3 and lower
+check { $b = $a } { get => 1 }, 'assign to';
+is $b, $n, 'get: assign to correctly';
 
-$b = "X${a}Y";
-ok($c == 2, 'get : interpolate');
-ok($b eq "X${n}Y", 'get : interpolate correctly');
+$b = check { "X${a}Y" } { get => 1 }, 'interpolate';
+is $b, "X${n}Y", 'get: interpolate correctly';