File Coverage

File:t/10-has.t
Coverage:100.0%

linestmtbrancondsubpodtimecode
1#!perl
2
3
3
3
3
7980
149209
11
use Test::Most;
4
5
3
3
3
50930
15559
8
use Moo;
6
7
3
3
3
3532
116536
24
use Types::Standard -types;
8
9
3
3
3
10617
11
19
use MooX::Const v0.2.0;
10
11throws_ok {
12
13
3
166
    has a => ( is => 'const', isa => 'Foo' );
14
15
3
179573
} qr/isa must be a Type::Tiny type/;
16
17throws_ok {
18
19
3
189
    has b => ( is => 'wo', isa => Str );
20
21
3
2135
} qr/write-once attributes are not supported for Value types/;
22
23throws_ok {
24
25
3
181
    has c => ( is => 'const', isa => InstanceOf['Thing'] );
26
27
3
1846
} qr/isa cannot be a type of Types::Standard::Object/;
28
29throws_ok {
30
31
3
200
    has d => ( is => 'wo', isa => InstanceOf['Thing'] );
32
33
3
2063
} qr/isa cannot be a type of Types::Standard::Object/;
34
35throws_ok {
36
37
3
214
    has e => ( is => 'const', isa => Ref, trigger => sub {}  );
38
39
3
1838
} qr/triggers are not applicable to const attributes/;
40
41lives_ok {
42
43
3
117
    has f => ( is => 'wo', isa => Ref, trigger => sub {}  );
44
45
3
1865
} 'triggers allowed for write-once attributes';
46
47throws_ok {
48
49
3
205
    has g => ( is => 'const' );
50
51
3
37383
} qr/Missing isa for a const attribute/;
52
53throws_ok {
54
55
3
181
    has h => ( is => 'const', isa => Undef );
56
57
3
1899
} qr/isa must be a type of Types::Standard::Ref/;
58
59
3
1736
done_testing;