Regenerate test files
[gitmo/Mouse.git] / t / 030_roles / 016_runtime_roles_and_nonmoose.t
CommitLineData
67199842 1#!/usr/bin/perl
fde8e43f 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;
67199842 5
6use strict;
7use warnings;
8
6475f69d 9use Test::More;
67199842 10use Test::Exception;
11use Scalar::Util 'blessed';
12
13
67199842 14{
15 package Dog;
16 use Mouse::Role;
17
18 sub talk { 'woof' }
19
20 package Foo;
21 use Mouse;
22
23 has 'dog' => (
24 is => 'rw',
25 does => 'Dog',
26 );
27
28 no Mouse;
29
30 package Bar;
31
32 sub new {
33 return bless {}, shift;
34 }
35}
36
37my $bar = Bar->new;
6cfa1e5e 38isa_ok($bar, 'Bar');
67199842 39
40my $foo = Foo->new;
6cfa1e5e 41isa_ok($foo, 'Foo');
67199842 42
43ok(!$bar->can( 'talk' ), "... the role is not composed yet");
44
45dies_ok {
46 $foo->dog($bar)
47} '... and setting the accessor fails (not a Dog yet)';
48
49Dog->meta->apply($bar);
50
51ok($bar->can('talk'), "... the role is now composed at the object level");
52
53is($bar->talk, 'woof', '... got the right return value for the newly composed method');
54
55lives_ok {
56 $foo->dog($bar)
57} '... and setting the accessor is okay';
58
6475f69d 59done_testing;