#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More;
use Test::Exception;
my %values_for_type = (
Any => {
- valid => ["foo"],
+ valid => [
+ undef,
+ \undef,
+ 1.0,
+ "foo",
+ \"foo",
+ sub { die },
+ qr/^1?$|^(11+?)\1+$/,
+ [],
+ {},
+ \do { my $v },
+ Test::Builder->new,
+ ],
invalid => [],
},
Item => {
- valid => [],
+ #valid => [], # populated later with the values from Any
invalid => [],
},
Bool => {
- valid => [],
- invalid => [],
+ valid => [undef, "", 1, 0, "1", "0"],
+ invalid => [1.5, "true", "false", "t", "f", ],
},
Undef => {
},
);
+$values_for_type{Item}{valid} = $values_for_type{Any}{valid};
+
+my $plan = 0;
+$plan += 5 * @{ $values_for_type{$_}{valid} } for keys %values_for_type;
+$plan += 4 * @{ $values_for_type{$_}{invalid} } for keys %values_for_type;
+$plan++; # can_ok
+
+plan tests => $plan;
+
do {
package Class;
use Mouse;
my $via_new;
throws_ok {
$via_new = Class->new($type => $value);
- } qr/(?!)/;
+ } qr/Attribute \($type\) does not pass the type constraint because: Validation failed for '$type' failed with value \Q$value\E/;
is($via_new, undef, "no object created");
my $via_set = Class->new;
throws_ok {
$via_set->$type($value);
- } qr/(?!)/;
+ } qr/Attribute \($type\) does not pass the type constraint because: Validation failed for '$type' failed with value \Q$value\E/;
is($via_set->$type, undef, "value for $type not set");
}