summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mro.c2
-rw-r--r--t/mro/basic.t21
2 files changed, 17 insertions, 6 deletions
diff --git a/mro.c b/mro.c
index 525076f2eb..f3db7745aa 100644
--- a/mro.c
+++ b/mro.c
@@ -718,7 +718,7 @@ XS(XS_mro_get_linear_isa) {
const struct mro_alg *const algo = S_get_mro_from_name(aTHX_ which);
if (!algo)
Perl_croak(aTHX_ "Invalid mro name: '%s'", which);
- algo->resolve(aTHX_ class_stash, 0);
+ RETVAL = algo->resolve(aTHX_ class_stash, 0);
}
else {
RETVAL = mro_get_linear_isa(class_stash);
diff --git a/t/mro/basic.t b/t/mro/basic.t
index 695306cf61..a4a61924d2 100644
--- a/t/mro/basic.t
+++ b/t/mro/basic.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-require q(./test.pl); plan(tests => 29);
+require q(./test.pl); plan(tests => 35);
{
package MRO_A;
@@ -20,18 +20,29 @@ require q(./test.pl); plan(tests => 29);
our @ISA = qw/MRO_D MRO_E/;
}
+my @MFO_F_DFS = qw/MRO_F MRO_D MRO_A MRO_B MRO_C MRO_E/;
+my @MFO_F_C3 = qw/MRO_F MRO_D MRO_E MRO_A MRO_B MRO_C/;
is(mro::get_mro('MRO_F'), 'dfs');
ok(eq_array(
- mro::get_linear_isa('MRO_F'),
- [qw/MRO_F MRO_D MRO_A MRO_B MRO_C MRO_E/]
+ mro::get_linear_isa('MRO_F'), \@MFO_F_DFS
));
+
+ok(eq_array(mro::get_linear_isa('MRO_F', 'dfs'), \@MFO_F_DFS));
+ok(eq_array(mro::get_linear_isa('MRO_F', 'c3'), \@MFO_F_C3));
+eval{mro::get_linear_isa('MRO_F', 'C3')};
+like($@, qr/^Invalid mro name: 'C3'/);
+
mro::set_mro('MRO_F', 'c3');
is(mro::get_mro('MRO_F'), 'c3');
ok(eq_array(
- mro::get_linear_isa('MRO_F'),
- [qw/MRO_F MRO_D MRO_E MRO_A MRO_B MRO_C/]
+ mro::get_linear_isa('MRO_F'), \@MFO_F_C3
));
+ok(eq_array(mro::get_linear_isa('MRO_F', 'dfs'), \@MFO_F_DFS));
+ok(eq_array(mro::get_linear_isa('MRO_F', 'c3'), \@MFO_F_C3));
+eval{mro::get_linear_isa('MRO_F', 'C3')};
+like($@, qr/^Invalid mro name: 'C3'/);
+
my @isarev = sort { $a cmp $b } @{mro::get_isarev('MRO_B')};
ok(eq_array(
\@isarev,