This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
threads 1.62
[perl5.git] / t / mro / basic.t
CommitLineData
e1a479c5
BB
1#!./perl
2
3use strict;
4use warnings;
5
c94dd5be 6require q(./test.pl); plan(tests => 8);
e1a479c5
BB
7
8{
9 package MRO_A;
10 our @ISA = qw//;
11 package MRO_B;
12 our @ISA = qw//;
13 package MRO_C;
14 our @ISA = qw//;
15 package MRO_D;
16 our @ISA = qw/MRO_A MRO_B MRO_C/;
17 package MRO_E;
18 our @ISA = qw/MRO_A MRO_B MRO_C/;
19 package MRO_F;
20 our @ISA = qw/MRO_D MRO_E/;
21}
22
23is(mro::get_mro('MRO_F'), 'dfs');
c94dd5be
RGS
24ok(eq_array(
25 mro::get_linear_isa('MRO_F'),
e1a479c5 26 [qw/MRO_F MRO_D MRO_A MRO_B MRO_C MRO_E/]
c94dd5be 27));
e1a479c5
BB
28mro::set_mro('MRO_F', 'c3');
29is(mro::get_mro('MRO_F'), 'c3');
c94dd5be
RGS
30ok(eq_array(
31 mro::get_linear_isa('MRO_F'),
e1a479c5 32 [qw/MRO_F MRO_D MRO_E MRO_A MRO_B MRO_C/]
c94dd5be 33));
e1a479c5
BB
34
35my @isarev = sort { $a cmp $b } mro::get_isarev('MRO_B');
c94dd5be
RGS
36ok(eq_array(
37 \@isarev,
e1a479c5 38 [qw/MRO_D MRO_E MRO_F/]
c94dd5be 39));
e1a479c5
BB
40
41ok(!mro::is_universal('MRO_B'));
42
43@UNIVERSAL::ISA = qw/MRO_F/;
44ok(mro::is_universal('MRO_B'));
45
46@UNIVERSAL::ISA = ();
47ok(mro::is_universal('MRO_B'));