Commit | Line | Data |
ee5e6a03 |
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 | use strict; |
6 | use warnings; |
7 | use Test::More; |
8 | use Test::Exception; |
9 | |
10 | { |
11 | package Point; |
12 | use Mouse; |
13 | |
14 | with qw/DoesNegated DoesTranspose/; |
15 | |
16 | has x => ( isa => 'Int', is => 'rw' ); |
17 | has y => ( isa => 'Int', is => 'rw' ); |
18 | |
19 | sub inspect { [$_[0]->x, $_[0]->y] } |
20 | |
21 | no Mouse; |
22 | } |
23 | |
24 | { |
25 | package DoesNegated; |
26 | use Mouse::Role; |
27 | |
28 | sub negated { |
29 | my $self = shift; |
30 | $self->new( x => -$self->x, y => -$self->y ); |
31 | } |
32 | |
33 | no Mouse::Role; |
34 | } |
35 | |
36 | { |
37 | package DoesTranspose; |
38 | use Mouse::Role; |
39 | |
40 | sub transpose { |
41 | my $self = shift; |
42 | $self->new( x => $self->y, y => $self->x ); |
43 | } |
44 | |
45 | no Mouse::Role; |
46 | } |
47 | |
48 | my $p = Point->new( x => 4, y => 3 ); |
49 | |
50 | DoesTranspose->meta->apply( $p, -alias => { transpose => 'negated' } ); |
51 | |
52 | is_deeply($p->negated->inspect, [3, 4]); |
53 | is_deeply($p->transpose->inspect, [3, 4]); |
54 | |
55 | done_testing; |