File: basic.t

package info (click to toggle)
libmoosex-undeftolerant-perl 0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 232 kB
  • sloc: perl: 507; makefile: 11
file content (38 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
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
32
33
34
35
36
37
38
use Test::More;
use Test::Moose;

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

has 'bar' => (
    is => 'ro',
    isa => 'Num',
    predicate => 'has_bar'
);

__PACKAGE__->meta->make_immutable;
}

package main;

with_immutable {
    {
        my $foo = Foo->new;
        ok(!$foo->has_bar);
    }

    {
        my $foo = Foo->new(bar => undef);
        ok(!$foo->has_bar);
    }

    {
        my $foo = Foo->new(bar => 1234);
        cmp_ok($foo->bar, 'eq', 1234);
        ok($foo->has_bar);
    }
} 'Foo';

done_testing;