From: Robert Sedlacek Date: Sat, 26 Nov 2011 00:30:36 +0000 (+0100) Subject: added more tests X-Git-Tag: v1.000000~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bf4fbb429bb9e9b19fc5db79962597712b08bfb;p=p5sagit%2FPackage-Variant.git added more tests --- diff --git a/t/10argument-types.t b/t/10argument-types.t new file mode 100644 index 0000000..77b7016 --- /dev/null +++ b/t/10argument-types.t @@ -0,0 +1,23 @@ +use strictures 1; +use Test::More; + +BEGIN { + package TestVariable; + use Package::Variant; + sub make_variant { + my ($class, $target, @args) = @_; + install variant_values => sub { [@args] }; + } + $INC{'TestVariable.pm'} = __FILE__; +} + +use TestVariable; + +is_deeply TestVariable(23)->variant_values, [23], + 'simple value argument'; +is_deeply TestVariable(3..7)->variant_values, [3..7], + 'multiple value arguments'; +is_deeply TestVariable({ foo => 23 })->variant_values, [{ foo => 23 }], + 'hash reference argument'; + +done_testing; diff --git a/t/11dynamic-build.t b/t/11dynamic-build.t new file mode 100644 index 0000000..75f49df --- /dev/null +++ b/t/11dynamic-build.t @@ -0,0 +1,21 @@ +use strictures 1; +use Test::More; + +BEGIN { + package TestVariable; + use Package::Variant; + sub make_variant { + my ($class, $target, @args) = @_; + install variant_values => sub { [@args] }; + } +} + +is_deeply( + Package::Variant + ->build_variant_of('TestVariable', 3..7) + ->variant_values, + [3..7], + 'build_variant_of with scalar values', +); + +done_testing;