Commit | Line | Data |
554b7648 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
e5efd577 |
10 | unless ( eval 'use Test::Warn 0.11; 1' ) { |
11 | plan skip_all => 'These tests require Test::Warn 0.11+'; |
554b7648 |
12 | } |
13 | else { |
14 | plan tests => 4; |
15 | } |
16 | } |
17 | |
18 | { |
19 | package MyApp::Base; |
20 | use Moose; |
21 | |
22 | extends 'Moose::Object'; |
23 | |
24 | before 'new' => sub { warn "Making a new " . $_[0] }; |
25 | |
26 | no Moose; |
27 | } |
28 | |
29 | { |
30 | package MyApp::UseMyBase; |
31 | use Moose (); |
32 | use Moose::Exporter; |
33 | |
aedcb7d9 |
34 | Moose::Exporter->setup_import_methods( also => 'Moose' ); |
554b7648 |
35 | |
36 | sub init_meta { |
37 | shift; |
38 | Moose->init_meta( @_, base_class => 'MyApp::Base' ); |
39 | } |
40 | } |
41 | |
42 | { |
43 | package Foo; |
44 | |
45 | MyApp::UseMyBase->import; |
46 | |
47 | has( 'size' => ( is => 'rw' ) ); |
48 | } |
49 | |
50 | ok( Foo->isa('MyApp::Base'), |
51 | 'Foo isa MyApp::Base' ); |
52 | |
53 | ok( Foo->can('size'), |
54 | 'Foo has a size method' ); |
55 | |
56 | my $foo; |
57 | warning_is( sub { $foo = Foo->new( size => 2 ) }, |
58 | 'Making a new Foo', |
59 | 'got expected warning when calling Foo->new' ); |
60 | |
61 | is( $foo->size(), 2, '$foo->size is 2' ); |
62 | |