From: gfx Date: Wed, 7 Oct 2009 03:07:02 +0000 (+0900) Subject: Add test for Mouse::Exporter X-Git-Tag: 0.37_03~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82657d71333fb807a2b0749e51b6ecc15a625024;p=gitmo%2FMouse.git Add test for Mouse::Exporter --- diff --git a/t/055-exporter.t b/t/055-exporter.t new file mode 100644 index 0000000..c089885 --- /dev/null +++ b/t/055-exporter.t @@ -0,0 +1,64 @@ +#!perl +use strict; +use warnings; +use Test::More tests => 14; + +use Mouse (); + +BEGIN{ + package MyMouse; + use Mouse; + Mouse::Exporter->setup_import_methods( + as_is => [qw(foo)], + also => [qw(Mouse)], + ); + + sub foo{ 100 } + + $INC{'MyMouse.pm'}++; + + package MyMouseEx; + use Mouse; + Mouse::Exporter->setup_import_methods( + as_is => [\&bar], + also => [qw(MyMouse)], + ); + + sub bar{ 200 } + + $INC{'MyMouseEx.pm'}++; +} + +can_ok 'MyMouse', qw(import unimport); +can_ok 'MyMouseEx', qw(import unimport); + +{ + package MyApp; + use Test::More; + use MyMouse; + + can_ok __PACKAGE__, 'meta'; + ok defined(&foo), 'foo is imported'; + ok defined(&has), 'has is also imported'; + + no MyMouse; + + ok !defined(&foo), 'foo is unimported'; + ok !defined(&has), 'has is also unimported'; +} +{ + package MyAppEx; + use Test::More; + use MyMouseEx; + + can_ok __PACKAGE__, 'meta'; + ok defined(&foo), 'foo is imported'; + ok defined(&bar), 'foo is also imported'; + ok defined(&has), 'has is also imported'; + + no MyMouseEx; + + ok !defined(&foo), 'foo is unimported'; + ok !defined(&bar), 'foo is also unimported'; + ok !defined(&has), 'has is also unimported'; +}