Remove our (now broken) dzil GatherDir subclass
[gitmo/Moose.git] / t / native_traits / array_trigger.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 {
7     package Foo;
8     use Moose;
9
10     our @TriggerArgs;
11
12     has array => (
13         traits  => ['Array'],
14         is      => 'rw',
15         isa     => 'ArrayRef',
16         handles => {
17             push_array => 'push',
18             set_array  => 'set',
19         },
20         clearer => 'clear_array',
21         trigger => sub { @TriggerArgs = @_ },
22     );
23 }
24
25 my $foo = Foo->new;
26
27 {
28     $foo->array( [ 1, 2, 3 ] );
29
30     is_deeply(
31         \@Foo::TriggerArgs,
32         [ $foo, [ 1, 2, 3 ] ],
33         'trigger was called for normal writer'
34     );
35
36     $foo->push_array(5);
37
38     is_deeply(
39         \@Foo::TriggerArgs,
40         [ $foo, [ 1, 2, 3, 5 ], [ 1, 2, 3 ] ],
41         'trigger was called on push'
42     );
43
44     $foo->set_array( 1, 42 );
45
46     is_deeply(
47         \@Foo::TriggerArgs,
48         [ $foo, [ 1, 42, 3, 5 ], [ 1, 2, 3, 5 ] ],
49         'trigger was called on set'
50     );
51 }
52
53 done_testing;