7b3c57917592801a5457dd85eff441f4daa2e2b0
[gitmo/MooseX-UndefTolerant.git] / t / undef_init_arg.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 7;
5 use Test::Fatal;
6 use Test::Moose;
7 use Test::NoWarnings 0.94 ':early';
8
9 {
10 package Foo;
11 use Moose;
12 use MooseX::UndefTolerant;
13
14 has 'bar' => (
15     is => 'ro',
16     isa => 'Num',
17     init_arg => undef,
18 );
19 }
20
21 package main;
22
23 with_immutable
24 {
25     is(exception { my $foo = Foo->new }, undef, 'constructed with no args');
26
27     is(exception { my $foo = Foo->new(bar => undef) }, undef, 'constructed with undef value');
28
29     is(exception { my $foo = Foo->new(bar => 1234) }, undef, 'constructed with defined value');
30 } 'Foo';
31