use warnings;
use FindBin;
-use Test::More tests => 144;
+use Test::More;
use Test::Exception;
use Moose::Util::TypeConstraints;
subtype 'FilePath'
=> as 'Str'
- => where { $_ =~ m#^(/[a-zA-Z0-9_.-]+)+/?$#
- || $_ =~ m#^([c-zC-Z]:/[a-zA-Z0-9_.-]+)# };
+ # This used to try to _really_ check for a valid Unix or Windows
+ # path, but the regex wasn't quite right, and all we care about
+ # for the tests is that it rejects '/'
+ => where { $_ ne '/' };
{
package Baz;
use Moose;
::is( $obj, undef, "... the object is undef" );
}
{
- local $@;
- my $obj = eval { $pkg->new ( undef ); };
+ local $@;
+ my $obj = eval { $pkg->new ( notanattr => 1 ); };
::like( $@, qr/is required/, "... $pkg undef" );
::is( $obj, undef, "... the object is undef" );
}
{
- local $@;
+ local $@;
my $obj = eval { $pkg->new ( %param ); };
::like( $@, qr/is required/, "... $pkg undef param" );
::is( $obj, undef, "... the object is undef" );
}
{
- local $@;
+ local $@;
my $obj = eval { $pkg->new ( path => '/' ); };
::like( $@, qr/does not pass the type constraint/, "... $pkg root path forbidden" );
::is( $obj, undef, "... the object is undef" );
}
{
- local $@;
+ local $@;
my $obj = eval { $pkg->new ( path => '/this_path/does/not_exist' ); };
::like( $@, qr/does not exist/, "... $pkg non existing path" );
::is( $obj, undef, "... the object is undef" );
}
{
- local $@;
+ local $@;
my $obj = eval { $pkg->new ( path => $FindBin::Bin ); };
::is( $@, '', "... $pkg no error" );
::isa_ok( $obj, $pkg );
}
}
-1;
-
+done_testing;