Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 029_instance_application_role_args.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
5use strict;
6use warnings;
7use Test::More;
8use 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
48my $p = Point->new( x => 4, y => 3 );
49
50DoesTranspose->meta->apply( $p, -alias => { transpose => 'negated' } );
51
52is_deeply($p->negated->inspect, [3, 4]);
53is_deeply($p->transpose->inspect, [3, 4]);
54
55done_testing;