Prevent all attribute initializers from seeing the value when we remove it, not just...
[gitmo/MooseX-UndefTolerant.git] / t / immutable.t
CommitLineData
46e1f0a3 1use Test::More;
2
3package Foo;
4use Moose;
5use MooseX::UndefTolerant;
6
7has 'bar' => (
8 is => 'ro',
9 isa => 'Num',
10 predicate => 'has_bar'
11);
12
13__PACKAGE__->meta->make_immutable;
14
15package 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
33done_testing;