File: undef_init_arg.t

package info (click to toggle)
libmoosex-undeftolerant-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 252 kB
  • ctags: 22
  • sloc: perl: 487; makefile: 13
file content (31 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use strict;
use warnings;

use Test::More tests => 7;
use Test::Fatal;
use Test::Moose;
use Test::NoWarnings 1.04 ':early';

{
package Foo;
use Moose;
use MooseX::UndefTolerant;

has 'bar' => (
    is => 'ro',
    isa => 'Num',
    init_arg => undef,
);
}

package main;

with_immutable
{
    is(exception { my $foo = Foo->new }, undef, 'constructed with no args');

    is(exception { my $foo = Foo->new(bar => undef) }, undef, 'constructed with undef value');

    is(exception { my $foo = Foo->new(bar => 1234) }, undef, 'constructed with defined value');
} 'Foo';