]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/20-get.t
This is 0.64
[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) + (2 * 2) + 1;
7
8 use Variable::Magic qw<cast>;
9
10 use lib 't/lib';
11 use Variable::Magic::TestWatcher;
12 use Variable::Magic::TestValue;
13
14 my $wiz = init_watcher 'get', 'get';
15
16 my $n = int rand 1000;
17 my $a = $n;
18
19 watch { cast $a, $wiz } { }, 'cast';
20
21 my $b;
22 # $b has to be set inside the block for the test to pass on 5.8.3 and lower
23 watch { $b = $a } { get => 1 }, 'assign to';
24 is $b, $n, 'get: assign to correctly';
25
26 $b = watch { "X${a}Y" } { get => 1 }, 'interpolate';
27 is $b, "X${n}Y", 'get: interpolate correctly';
28
29 {
30  my $val = 0;
31
32  init_value $val, 'get', 'get';
33
34  value { my $x = $val } \0;
35 }