added more tests
Robert Sedlacek [Sat, 26 Nov 2011 00:30:36 +0000 (01:30 +0100)]
t/10argument-types.t [new file with mode: 0644]
t/11dynamic-build.t [new file with mode: 0644]

diff --git a/t/10argument-types.t b/t/10argument-types.t
new file mode 100644 (file)
index 0000000..77b7016
--- /dev/null
@@ -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 (file)
index 0000000..75f49df
--- /dev/null
@@ -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;