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