Small optimisations, by Brandon Black
[p5sagit/p5-mst-13.2.git] / t / mro / basic.t
1 #!./perl
2
3 use strict;
4 use warnings;
5
6 BEGIN {
7     unless (-d 'blib') {
8         chdir 't' if -d 't';
9         @INC = '../lib';
10     }
11 }
12
13 use Test::More;
14
15 plan tests => 8;
16
17 {
18     package MRO_A;
19     our @ISA = qw//;
20     package MRO_B;
21     our @ISA = qw//;
22     package MRO_C;
23     our @ISA = qw//;
24     package MRO_D;
25     our @ISA = qw/MRO_A MRO_B MRO_C/;
26     package MRO_E;
27     our @ISA = qw/MRO_A MRO_B MRO_C/;
28     package MRO_F;
29     our @ISA = qw/MRO_D MRO_E/;
30 }
31
32 is(mro::get_mro('MRO_F'), 'dfs');
33 is_deeply(mro::get_linear_isa('MRO_F'),
34     [qw/MRO_F MRO_D MRO_A MRO_B MRO_C MRO_E/]
35 );
36 mro::set_mro('MRO_F', 'c3');
37 is(mro::get_mro('MRO_F'), 'c3');
38 is_deeply(mro::get_linear_isa('MRO_F'),
39     [qw/MRO_F MRO_D MRO_E MRO_A MRO_B MRO_C/]
40 );
41
42 my @isarev = sort { $a cmp $b } mro::get_isarev('MRO_B');
43 is_deeply(\@isarev,
44     [qw/MRO_D MRO_E MRO_F/]
45 );
46
47 ok(!mro::is_universal('MRO_B'));
48
49 @UNIVERSAL::ISA = qw/MRO_F/;
50 ok(mro::is_universal('MRO_B'));
51
52 @UNIVERSAL::ISA = ();
53 ok(mro::is_universal('MRO_B'));