summaryrefslogtreecommitdiffstats
path: root/t/defaults.t
blob: 7350d521ca4bc4a4d21c8f16ee96d20f15ad7cce (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Fatal;

{
    package Foo;
    use Moose;
    use Bread::Board::Declare;

    ::like(::exception {
        has foo => (
            is      => 'ro',
            isa     => 'Str',
            default => 'OOF',
            value   => 'FOO',
        );
    }, qr/default is not valid when Bread::Board service options are set/,
       "can't set a default when creating a service");

    ::like(::exception {
        has bar => (
            is      => 'ro',
            isa     => 'Str',
            default => sub { 'OOF' },
            value   => 'FOO',
        );
    }, qr/default is not valid when Bread::Board service options are set/,
       "can't set a default when creating a service");

    ::like(::exception {
        has bar2 => (
            is      => 'ro',
            isa     => 'Str',
            builder => '_build_bar2',
            value   => 'FOO',
        );
    }, qr/builder is not valid when Bread::Board service options are set/,
       "can't set a builder when creating a service");

    ::like(::exception {
        has baz => (
            is      => 'ro',
            isa     => 'Str',
            lazy    => 1,
            default => 'OOF',
            value   => 'FOO',
        );
    }, qr/default is not valid when Bread::Board service options are set/,
       "can't set a default when creating a service");

    ::like(::exception {
        has quux => (
            is      => 'ro',
            isa     => 'Str',
            lazy    => 1,
            default => sub { 'OOF' },
            value   => 'FOO',
        );
    }, qr/default is not valid when Bread::Board service options are set/,
       "can't set a default when creating a service");

    ::like(::exception {
        has quux2 => (
            is      => 'ro',
            isa     => 'Str',
            lazy    => 1,
            builder => '_build_quux2',
            value   => 'FOO',
        );
    }, qr/builder is not valid when Bread::Board service options are set/,
       "can't set a builder when creating a service");

    ::like(::exception {
        has quux3 => (
            is         => 'ro',
            isa        => 'Str',
            lazy_build => 1,
            value      => 'FOO',
        );
    }, qr/builder is not valid when Bread::Board service options are set/,
       "can't set lazy_build when creating a service");
}

done_testing;