]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/20-get.t
7548e15e20adfef567fac84fa407063e64755b00
[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 => 2 * 4 + 2 + 1;
7
8 use Variable::Magic qw/cast/;
9
10 use lib 't/lib';
11 use Variable::Magic::TestWatcher;
12
13 my $wiz = init_watcher 'get', 'get';
14
15 my $n = int rand 1000;
16 my $a = $n;
17
18 watch { cast $a, $wiz } { }, 'cast';
19
20 my $b;
21 # $b has to be set inside the block for the test to pass on 5.8.3 and lower
22 watch { $b = $a } { get => 1 }, 'assign to';
23 is $b, $n, 'get: assign to correctly';
24
25 $b = watch { "X${a}Y" } { get => 1 }, 'interpolate';
26 is $b, "X${n}Y", 'get: interpolate correctly';