X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01simple.t;h=e41d27f670f620e5956bf60fb32ff5a498334c79;hb=115c342b3d84b8dd078f7e3779358662927473fc;hp=6cb6406ddae569135bf3ed688b6d257b3530454f;hpb=b6086e0da219b3dc46281b04c574a02e4fa2b5a5;p=p5sagit%2FPackage-Variant.git diff --git a/t/01simple.t b/t/01simple.t index 6cb6406..e41d27f 100644 --- a/t/01simple.t +++ b/t/01simple.t @@ -61,4 +61,40 @@ is exception { is_deeply $renamed->args, [9..12], 'imported generator can be renamed'; }, undef, 'no errors for renamed usage'; +my @imported; +BEGIN { + package TestImportableA; + sub import { push @imported, shift } + $INC{'TestImportableA.pm'} = __FILE__; + package TestImportableB; + sub import { push @imported, shift } + $INC{'TestImportableB.pm'} = __FILE__; + package TestArrayImports; + use Package::Variant + importing => [ + 'TestImportableA', + 'TestImportableB', + ]; + sub make_variant { } + $INC{'TestArrayImports.pm'} = __FILE__; +} + +use TestArrayImports; +TestArrayImports(23); + +is_deeply [@imported], [qw( TestImportableA TestImportableB )], + 'multiple imports in the right order'; + +like exception { + Package::Variant->import( + importing => \'foo', subs => [qw( foo )], + ); +}, qr/importing.+option.+hash.+array/i, 'invalid "importing" option'; + +like exception { + Package::Variant->import( + importing => { foo => \'bar' }, subs => [qw( bar )], + ); +}, qr/import.+argument.+not.+array/i, 'invalid import argument list'; + done_testing;