]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/21-set.t
This is 0.64
[perl/modules/Variable-Magic.git] / t / 21-set.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => (2 * 5 + 3) + (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 'set', 'set';
15
16 my $a = 0;
17
18 watch { cast $a, $wiz } { }, 'cast';
19
20 my $n = int rand 1000;
21
22 watch { $a = $n } { set => 1 }, 'assign';
23 is $a, $n, 'set: assign correctly';
24
25 watch { ++$a } { set => 1 }, 'increment';
26 is $a, $n + 1, 'set: increment correctly';
27
28 watch { --$a } { set => 1 }, 'decrement';
29 is $a, $n, 'set: decrement correctly';
30
31 {
32  my $val = 0;
33
34  init_value $val, 'set', 'set';
35
36  value { $val = 1 } \1;
37 }