2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
13 use Mouse::Util::TypeConstraints;
17 # This used to try to _really_ check for a valid Unix or Windows
18 # path, but the regex wasn't quite right, and all we care about
19 # for the tests is that it rejects '/'
20 => where { $_ ne '/' };
24 use Mouse::Util::TypeConstraints;
33 my ( $self, $params ) = @_;
34 confess $params->{path} . " does not exist"
35 unless -e $params->{path};
38 # Defining this causes the FIRST call to Baz->new w/o param to fail,
39 # if no call to ANY Mouse::Object->new was done before.
48 use Mouse::Util::TypeConstraints;
57 my ( $self, $params ) = @_;
58 confess $params->{path} . " does not exist"
59 unless -e $params->{path};
62 # Defining this causes the FIRST call to Qee->new w/o param to fail...
63 # if no call to ANY Mouse::Object->new was done before.
72 use Mouse::Util::TypeConstraints;
81 my ( $self, $params ) = @_;
82 confess $params->{path} . " does not exist"
83 unless -e $params->{path};
86 # Having no DEMOLISH, everything works as expected...
89 check_em ( 'Baz' ); # 'Baz plain' will fail, aka NO error
90 check_em ( 'Qee' ); # ok
91 check_em ( 'Foo' ); # ok
93 check_em ( 'Qee' ); # 'Qee plain' will fail, aka NO error
94 check_em ( 'Baz' ); # ok
95 check_em ( 'Foo' ); # ok
97 check_em ( 'Foo' ); # ok
98 check_em ( 'Baz' ); # ok !
99 check_em ( 'Qee' ); # ok
106 # Uncomment to see, that it is really any first call.
107 # Subsequents calls will not fail, aka giving the correct error.
110 my $obj = eval { $pkg->new; };
111 ::like( $@, qr/is required/, "... $pkg plain" );
112 ::is( $obj, undef, "... the object is undef" );
116 my $obj = eval { $pkg->new(); };
117 ::like( $@, qr/is required/, "... $pkg empty" );
118 ::is( $obj, undef, "... the object is undef" );
122 my $obj = eval { $pkg->new ( notanattr => 1 ); };
123 ::like( $@, qr/is required/, "... $pkg undef" );
124 ::is( $obj, undef, "... the object is undef" );
129 my $obj = eval { $pkg->new ( %param ); };
130 ::like( $@, qr/is required/, "... $pkg undef param" );
131 ::is( $obj, undef, "... the object is undef" );
135 my $obj = eval { $pkg->new ( path => '/' ); };
136 ::like( $@, qr/does not pass the type constraint/, "... $pkg root path forbidden" );
137 ::is( $obj, undef, "... the object is undef" );
141 my $obj = eval { $pkg->new ( path => '/this_path/does/not_exist' ); };
142 ::like( $@, qr/does not exist/, "... $pkg non existing path" );
143 ::is( $obj, undef, "... the object is undef" );
147 my $obj = eval { $pkg->new ( path => $FindBin::Bin ); };
148 ::is( $@, '', "... $pkg no error" );
149 ::isa_ok( $obj, $pkg );
150 ::isa_ok( $obj, 'Mouse::Object' );
151 ::is( $obj->path, $FindBin::Bin, "... $pkg got the right value" );