summaryrefslogtreecommitdiff
path: root/t/exceptions/rt-92818.t
blob: b50484169229dc197e43f1a2f4f7add9f6e0b82c (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;

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

# https://rt.cpan.org/Ticket/Display.html?id=92818

{
    package Parent;
    use Moose;
    has x => (
        is => 'rw',
        required => 1,
    );
}

{
    my $e = exception { my $obj = Parent->new };
    ok(
        $e->isa('Moose::Exception::AttributeIsRequired'),
        'got the right exception',
    )
    or note 'got exception ', ref($e), ': ', $e->message;
}

{
    package Child;
    use Moose;
    extends 'Parent';
}

# the exception produced should be AttributeIsRequired, however
# AttributeIsRequired was throwing the exception ClassNamesDoNotMatch.

{
    my $e = exception { my $obj = Child->new };
    ok(
        $e->isa('Moose::Exception::AttributeIsRequired'),
        'got the right exception',
    )
    or note 'got exception ', ref($e), ': ', $e->message;
}

done_testing;