with_immutable needs to test both mutable and immutable conditions
[gitmo/MooseX-UndefTolerant.git] / t / basic.t
1 use strict;
2 use warnings;
3
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 }
19
20 package main;
21
22 with_immutable {
23     {
24         my $foo = Foo->new;
25         ok(!$foo->has_bar);
26     }
27
28     {
29         my $foo = Foo->new(bar => undef);
30         ok(!$foo->has_bar);
31     }
32
33     {
34         my $foo = Foo->new(bar => 1234);
35         cmp_ok($foo->bar, 'eq', 1234);
36         ok($foo->has_bar);
37     }
38 } 'Foo';
39
40 done_testing;