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