Commit | Line | Data |
f9aca0f3 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use Test::More 'no_plan'; |
5 | use Test::Exception; |
6 | $| = 1; |
7 | |
8 | |
9 | |
10 | # =begin testing SETUP |
11 | BEGIN { |
12 | eval 'use Test::Output;'; |
13 | if ($@) { |
14 | diag 'Test::Output is required for this test'; |
15 | ok(1); |
16 | exit 0; |
17 | } |
18 | } |
19 | |
20 | |
21 | |
22 | # =begin testing SETUP |
23 | { |
24 | |
25 | package MyApp::Base; |
26 | use Mouse; |
27 | |
28 | extends 'Mouse::Object'; |
29 | |
30 | before 'new' => sub { warn "Making a new " . $_[0] }; |
31 | |
32 | no Mouse; |
33 | |
34 | package MyApp::UseMyBase; |
35 | use Mouse (); |
36 | use Mouse::Exporter; |
37 | |
38 | Mouse::Exporter->setup_import_methods( also => 'Mouse' ); |
39 | |
40 | sub init_meta { |
41 | shift; |
42 | return Mouse->init_meta( @_, base_class => 'MyApp::Base' ); |
43 | } |
44 | } |
45 | |
46 | |
47 | |
48 | # =begin testing |
49 | { |
50 | { |
51 | package Foo; |
52 | |
53 | MyApp::UseMyBase->import; |
54 | |
55 | has( 'size' => ( is => 'rw' ) ); |
56 | } |
57 | |
58 | ok( Foo->isa('MyApp::Base'), 'Foo isa MyApp::Base' ); |
59 | |
60 | ok( Foo->can('size'), 'Foo has a size method' ); |
61 | |
62 | my $foo; |
63 | stderr_like( |
64 | sub { $foo = Foo->new( size => 2 ) }, |
65 | qr/^Making a new Foo/, |
66 | 'got expected warning when calling Foo->new' |
67 | ); |
68 | |
69 | is( $foo->size(), 2, '$foo->size is 2' ); |
70 | } |
71 | |
72 | |
73 | |
74 | |
75 | 1; |