Commit | Line | Data |
fde8e43f |
1 | #!/usr/bin/perl |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
9 | use Test::More; |
10 | $TODO = q{Mouse is not yet completed}; |
11 | use Test::Mouse 'does_ok'; |
12 | |
13 | { |
14 | package MyHomePage; |
15 | use Mouse; |
16 | |
17 | has 'counter' => ( |
18 | traits => ['Counter'], |
19 | is => 'ro', |
20 | isa => 'Int', |
21 | default => 0, |
22 | handles => { |
23 | inc_counter => 'inc', |
24 | dec_counter => 'dec', |
25 | reset_counter => 'reset', |
26 | set_counter => 'set' |
27 | } |
28 | ); |
29 | } |
30 | |
31 | my $page = MyHomePage->new(); |
32 | isa_ok( $page, 'MyHomePage' ); |
33 | |
34 | can_ok( $page, $_ ) for qw[ |
35 | dec_counter |
36 | inc_counter |
37 | reset_counter |
38 | set_counter |
39 | ]; |
40 | |
41 | is( $page->counter, 0, '... got the default value' ); |
42 | |
43 | $page->inc_counter; |
44 | is( $page->counter, 1, '... got the incremented value' ); |
45 | |
46 | $page->inc_counter; |
47 | is( $page->counter, 2, '... got the incremented value (again)' ); |
48 | |
49 | $page->dec_counter; |
50 | is( $page->counter, 1, '... got the decremented value' ); |
51 | |
52 | $page->reset_counter; |
53 | is( $page->counter, 0, '... got the original value' ); |
54 | |
55 | $page->set_counter(5); |
56 | is( $page->counter, 5, '... set the value' ); |
57 | |
58 | $page->inc_counter(2); |
59 | is( $page->counter, 7, '... increment by arg' ); |
60 | |
61 | $page->dec_counter(5); |
62 | is( $page->counter, 2, '... decrement by arg' ); |
63 | |
64 | # check the meta .. |
65 | |
66 | my $counter = $page->meta->get_attribute('counter'); |
67 | does_ok( $counter, 'Mouse::Meta::Attribute::Native::Trait::Counter' ); |
68 | |
69 | is( $counter->type_constraint->name, 'Int', |
70 | '... got the expected type constraint' ); |
71 | |
72 | is_deeply( |
73 | $counter->handles, |
74 | { |
75 | inc_counter => 'inc', |
76 | dec_counter => 'dec', |
77 | reset_counter => 'reset', |
78 | set_counter => 'set' |
79 | }, |
80 | '... got the right handles methods' |
81 | ); |
82 | |
83 | done_testing; |