with_immutable needs to test both mutable and immutable conditions
[gitmo/MooseX-UndefTolerant.git] / t / basic.t
CommitLineData
4fbe5d7d 1use strict;
2use warnings;
3
cd954cc2 4use Test::More;
5use Test::Moose;
6
7{
8package Foo;
9use Moose;
10use MooseX::UndefTolerant;
11
12has 'bar' => (
13 is => 'ro',
14 isa => 'Num',
15 predicate => 'has_bar'
16);
17
cd954cc2 18}
19
20package main;
21
22with_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
40done_testing;