File: 001_exception_reflects_failed_constraint.t

package info (click to toggle)
libmoose-perl 1.09-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,004 kB
  • ctags: 1,472
  • sloc: perl: 25,387; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 821 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
#!/usr/bin/perl

# 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 strict;
use warnings;

use Test::More;
use Test::Exception;

BEGIN {
    use_ok('Moose::Util::TypeConstraints');
}

lives_ok {
    subtype 'ParentConstraint' => as 'Str' => where {0};
} 'specified parent type constraint';

my $tc;
lives_ok {
    $tc = subtype 'ChildConstraint' => as 'ParentConstraint' => where {1};
} '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;