diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-08-20 21:09:03 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-08-20 21:09:03 +0100 |
commit | b0413f463ee989f4bfc29e4acfcfc4873d4dc3ce (patch) | |
tree | fbacfb281af497d07597e1cf4d5de678df6de04f /t/mro | |
parent | d7c0d2821cad1d2e5b6b3d6440e7c22bfaae9559 (diff) | |
download | perl-b0413f463ee989f4bfc29e4acfcfc4873d4dc3ce.tar.gz |
Optimise mro_get_linear_isa_c3() when there is a single parent. 40% speed up.
Idea blatantly copied from chromatic's analogous change to parrot, r38477.
Diffstat (limited to 't/mro')
-rw-r--r-- | t/mro/isa_c3.t | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/t/mro/isa_c3.t b/t/mro/isa_c3.t new file mode 100644 index 0000000000..713d10ef3a --- /dev/null +++ b/t/mro/isa_c3.t @@ -0,0 +1,69 @@ +#!perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require "./test.pl"; +} + +use strict; + +plan 'no_plan'; + +# package klonk doesn't have a stash. + +package kapow; +use mro 'c3'; + +# No parents + +package urkkk; +use mro 'c3'; + +# 1 parent +@urkkk::ISA = 'klonk'; + +package kayo; +use mro 'c3'; + +# 2 parents +@urkkk::ISA = ('klonk', 'kapow'); + +package thwacke; +use mro 'c3'; + +# No parents, has @ISA +@thwacke::ISA = (); + +package zzzzzwap; +use mro 'c3'; + +@zzzzzwap::ISA = ('thwacke', 'kapow'); + +package whamm; +use mro 'c3'; + +@whamm::ISA = ('kapow', 'thwacke'); + +package main; + +my %expect = + ( + klonk => [qw(klonk)], + urkkk => [qw(urkkk klonk kapow)], + kapow => [qw(kapow)], + kayo => [qw(kayo)], + thwacke => [qw(thwacke)], + zzzzzwap => [qw(zzzzzwap thwacke kapow)], + whamm => [qw(whamm kapow thwacke)], + ); + +foreach my $package (qw(klonk urkkk kapow kayo thwacke zzzzzwap whamm)) { + my $ref = bless [], $package; + my $isa = $expect{$package}; + is("@{mro::get_linear_isa($package)}", "@$isa", "\@ISA for $package"); + + foreach my $class ($package, @$isa, 'UNIVERSAL') { + isa_ok($ref, $class, $package); + } +} |