X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01simple.t;h=3d3813dd4996420bf6fe1b84af9fb81aab7947c2;hb=85613afadac05208e237d0f0c5a96dcd164cc3dd;hp=dac661c38c72c0ab6bca180d7b92ac1c2a54b8eb;hpb=efaab2573dd1acde9c72d8ce02ba9e1ad6c6e6e6;p=p5sagit%2FPackage-Variant.git diff --git a/t/01simple.t b/t/01simple.t index dac661c..3d3813d 100644 --- a/t/01simple.t +++ b/t/01simple.t @@ -85,4 +85,50 @@ 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'; + +@imported = (); + +TestSingleImport::->build_variant; + +is_deeply [@imported], [qw( TestImportableA )], + 'build_variant 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;