/
03-moosex-types.t
53 lines (48 loc) · 1.18 KB
/
03-moosex-types.t
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
use strict;
use warnings FATAL => 'all';
use Test::Tester 0.108;
# FIXME: we should be able to pass an import arg to Test::Requires
BEGIN {
use Test::Requires 'MooseX::Types::Moose';
MooseX::Types::Moose->import('Str');
}
use Test::More tests => 16;
use Test::NoWarnings 1.04 ':early';
use Test::Fatal;
use Test::Deep;
use Test::Deep::Type;
check_tests(
sub {
cmp_deeply(
{ message => 'ack I am slain' },
{ message => is_type(Str) },
'message is a string',
);
cmp_deeply(
{ message => { foo => 1 } },
{ message => is_type(Str) },
'message is a string',
);
},
[
{
actual_ok => 1,
ok => 1,
diag => '',
name => 'message is a string',
type => '',
},
{
actual_ok => 0,
ok => 0,
name => 'message is a string',
type => '',
diag => <<EOM,
Validating \$data->{"message"} as a Str type
got : Validation failed for 'Str' with value { foo: 1 }
expect : no error
EOM
},
],
'success and failure with a MooseX::Types type',
);