From 84dccb35f7809a3cd00c6b11d0a9aa40b70e045f Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 26 Sep 2007 16:32:45 +0000 Subject: [PATCH] Change 31977 introduced a bug (failing to set the return value of mro::get_linear_isa() when passed a second parameter). However, there were no tests for this. Fix both. p4raw-id: //depot/perl@31981 --- mro.c | 2 +- t/mro/basic.t | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mro.c b/mro.c index 525076f..f3db774 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 695306c..a4a6192 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, -- 2.7.4