Merge branch 'stable'
[gitmo/Class-MOP.git] / t / 303_RT_39001_fix.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use Test::Fatal;
5
6 use Class::MOP;
7
8 =pod
9
10 This tests a bug sent via RT #39001
11
12 =cut
13
14 {
15     package Foo;
16     use metaclass;
17 }
18
19 like( exception {
20     Foo->meta->superclasses('Foo');
21 }, qr/^Recursive inheritance detected/, "error occurs when extending oneself" );
22
23 {
24     package Bar;
25     use metaclass;
26 }
27
28 # reset @ISA, so that calling methods like ->isa won't die (->meta does this
29 # if DEBUG_NO_META is set)
30 @Foo::ISA = ();
31
32 is( exception {
33     Foo->meta->superclasses('Bar');
34 }, undef, "regular subclass" );
35
36 like( exception {
37     Bar->meta->superclasses('Foo');
38 }, qr/^Recursive inheritance detected/, "error occurs when Bar extends Foo, when Foo is a Bar" );
39
40 done_testing;