summaryrefslogtreecommitdiff
path: root/t/mro
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-08-20 16:02:40 +0100
committerNicholas Clark <nick@ccl4.org>2009-08-20 16:02:40 +0100
commit73519bd01829f1480c288a0a7ccbfff973d867df (patch)
tree9bb2fedb609f7bb8f0ce0ad2da40cff96cd2f408 /t/mro
parentc3acb9e0760135dfd888c0ee1b415777d784aabc (diff)
downloadperl-73519bd01829f1480c288a0a7ccbfff973d867df.tar.gz
Optimise S_mro_get_linear_isa_dfs() when dealing with the first parent class.
Benchmarking with single inheritance suggests that this is 10% faster.
Diffstat (limited to 't/mro')
-rw-r--r--t/mro/isa_dfs.t53
1 files changed, 53 insertions, 0 deletions
diff --git a/t/mro/isa_dfs.t b/t/mro/isa_dfs.t
new file mode 100644
index 0000000000..6eabf1f27d
--- /dev/null
+++ b/t/mro/isa_dfs.t
@@ -0,0 +1,53 @@
+#!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;
+
+# No parents
+
+package urkkk;
+
+# 1 parent
+@urkkk::ISA = 'klonk';
+
+package kayo;
+
+# 2 parents
+@urkkk::ISA = ('klonk', 'kapow');
+
+package thwacke;
+
+# No parents, has @ISA
+@thwacke::ISA = ();
+
+package zzzzzwap;
+
+@zzzzzwap::ISA = ('thwacke', 'kapow');
+
+package whamm;
+
+@whamm::ISA = ('kapow', 'thwacke');
+
+package main;
+
+require mro;
+
+foreach my $package (qw(klonk urkkk kapow kayo thwacke zzzzzwap whamm)) {
+ my $ref = bless [], $package;
+ my $isa = mro::get_linear_isa($package);
+
+ foreach my $class ($package, @$isa, 'UNIVERSAL') {
+ isa_ok($ref, $class, $package);
+ }
+}