summaryrefslogtreecommitdiff
path: root/t/todo_tests/exception_reflects_failed_constraint.t
blob: 6375fabc5ecb1c2dbb4b8385dfcfef8774d5d823 (plain)
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;

# In the case where a child type constraint's parent constraint fails,
# the exception should reference the parent type constraint that actually
# failed instead of always referencing the child'd type constraint

use Test::More;
use Test::Fatal;

use Moose::Util::TypeConstraints;

is( exception {
    subtype 'ParentConstraint' => as 'Str' => where {0};
}, undef, 'specified parent type constraint' );

my $tc;
is( exception {
    $tc = subtype 'ChildConstraint' => as 'ParentConstraint' => where {1};
}, undef, 'specified child type constraint' );

{
    my $errmsg = $tc->validate();

    TODO: {
        local $TODO = 'Not yet supported';
        ok($errmsg !~ /Validation failed for 'ChildConstraint'/, 'exception references failing parent constraint');
    };
}

done_testing;