]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/20-get.t
Importing Variable-Magic-0.04.tar.gz
[perl/modules/Variable-Magic.git] / t / 20-get.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 6;
7
8 use Variable::Magic qw/wizard cast/;
9
10 my $c = 0;
11 my $wiz = wizard get => sub { ++$c };
12 ok($c == 0, 'get : create wizard');
13
14 my $n = int rand 1000;
15 my $a = $n;
16
17 cast $a, $wiz;
18 ok($c == 0, 'get : cast');
19
20 my $b = $a;
21 ok($c == 1, 'get : assign to');
22 ok($b == $n, 'get : assign to correctly');
23
24 $b = "X${a}Y";
25 ok($c == 2, 'get : interpolate');
26 ok($b eq "X${n}Y", 'get : interpolate correctly');