Prevent all attribute initializers from seeing the value when we remove it, not just...
[gitmo/MooseX-UndefTolerant.git] / t / immutable.t
1 use Test::More;
2
3 package Foo;
4 use Moose;
5 use MooseX::UndefTolerant;
6
7 has 'bar' => (
8     is => 'ro',
9     isa => 'Num',
10     predicate => 'has_bar'
11 );
12
13 __PACKAGE__->meta->make_immutable;
14
15 package main;
16
17 {
18     my $foo = Foo->new;
19     ok(!$foo->has_bar);
20 }
21
22 {
23     my $foo = Foo->new(bar => undef);
24     ok(!$foo->has_bar);
25 }
26
27 {
28     my $foo = Foo->new(bar => 1234);
29     cmp_ok($foo->bar, 'eq', 1234);
30     ok($foo->has_bar);
31 }
32
33 done_testing;