X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01simple.t;h=2a060cb7544ea8b0ba3acc6ae70b6a77c3097e17;hb=203d81fc3c1966d9a28a96987ccf49c2b7bfde97;hp=2d518734430c11e5ccd99b36197485bffd317b66;hpb=815b5be2c946367c4d74c815599ea9d706c0f5e3;p=p5sagit%2FPackage-Variant.git diff --git a/t/01simple.t b/t/01simple.t index 2d51873..2a060cb 100644 --- a/t/01simple.t +++ b/t/01simple.t @@ -72,8 +72,8 @@ BEGIN { package TestArrayImports; use Package::Variant importing => [ - TestImportableA => undef, - TestImportableB => undef, + 'TestImportableA', + 'TestImportableB', ]; sub make_variant { } $INC{'TestArrayImports.pm'} = __FILE__; @@ -85,4 +85,43 @@ TestArrayImports(23); is_deeply [@imported], [qw( TestImportableA TestImportableB )], 'multiple imports in the right order'; +BEGIN { + package TestSingleImport; + use Package::Variant importing => 'TestImportableA'; + sub make_variant { } + $INC{'TestSingleImport.pm'} = __FILE__; +} + +@imported = (); + +use TestSingleImport; +TestSingleImport(23); + +is_deeply [@imported], [qw( TestImportableA )], + 'scalar import works'; + +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.+foo.+not.+array/i, 'invalid import argument list'; + +like exception { + Package::Variant->import( + importing => [ foo => ['bar'], ['bam'], subs => [qw( bar )] ], + ); +}, qr/value.+3.+importing.+not.+string/i, 'importing array invalid key'; + +like exception { + Package::Variant->import( + importing => [ foo => \'bam', subs => [qw( bar )] ], + ); +}, qr/value.+2.+foo.+importing.+array/i, 'importing array invalid list'; + done_testing;