Commit | Line | Data |
cd954cc2 |
1 | use Test::More; |
2 | use Test::Moose; |
3 | |
4 | { |
5 | package Foo; |
6 | use Moose; |
7 | use MooseX::UndefTolerant; |
8 | |
9 | has 'bar' => ( |
10 | is => 'ro', |
11 | isa => 'Num', |
12 | predicate => 'has_bar' |
13 | ); |
14 | |
15 | __PACKAGE__->meta->make_immutable; |
16 | } |
17 | |
18 | package main; |
19 | |
20 | with_immutable { |
21 | { |
22 | my $foo = Foo->new; |
23 | ok(!$foo->has_bar); |
24 | } |
25 | |
26 | { |
27 | my $foo = Foo->new(bar => undef); |
28 | ok(!$foo->has_bar); |
29 | } |
30 | |
31 | { |
32 | my $foo = Foo->new(bar => 1234); |
33 | cmp_ok($foo->bar, 'eq', 1234); |
34 | ok($foo->has_bar); |
35 | } |
36 | } 'Foo'; |
37 | |
38 | done_testing; |