Commit | Line | Data |
3a0c064a |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More no_plan => 1; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose'); |
11 | use_ok('Moose::Util::TypeConstraints'); |
12 | } |
13 | |
14 | { |
15 | package Foo; |
16 | use Moose; |
17 | |
18 | has 'bar' => ( |
19 | is => 'ro', |
20 | required => 1, |
21 | ); |
22 | |
23 | # Defining this causes the FIRST call to Baz->new w/o param to fail, |
24 | # if no call to ANY Moose::Object->new was done before. |
25 | sub DEMOLISH { |
26 | my ( $self ) = @_; |
27 | } |
28 | } |
29 | |
30 | my $obj = eval { Foo->new; }; |
31 | ::like( $@, qr/is required/, "... Foo plain" ); |
32 | ::is( $obj, undef, "... the object is undef" ); |
33 | |
34 | 1; |
35 | |