# New Ticket Created by Sam Vilain
# Please include the string: [perl #41454]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41454 >
Previously, inherited method dispatch was only tested with a simple
parent/child class. Add tests for method dispatch with three classes
in a straight line, as well as a simple 4-class diamond inheritance
heirarchy.
---
t/pmc/object-meths.t | 93 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/t/pmc/object-meths.t b/t/pmc/object-meths.t
index 403b7ff..38cfbbf 100644
--- a/t/pmc/object-meths.t
+++ b/t/pmc/object-meths.t
@@ -6,7 +6,7 @@ use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 36;
+use Parrot::Test tests => 38;
=head1 NAME
@@ -942,7 +942,7 @@ CODE
foofoo
OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "super 1" );
+pir_output_is( <<'CODE', <<'OUTPUT', "super 1 - two classes" );
.sub main :main
.local pmc o, cl
cl = newclass 'Parent'
@@ -973,6 +973,95 @@ Parent foo
Parent bar
OUTPUT
+pir_output_is( <<'CODE', <<'OUTPUT', "super 2 - three classes" );
+.sub main :main
+ .local pmc o, p, c, g
+ p = newclass 'Parent'
+ c = subclass p, 'Child'
+ g = subclass c, 'GrandChild'
+ o = new 'GrandChild'
+ o."foo"()
+.end
+
+.namespace ['Parent']
+.sub foo :method
+ print "Parent foo\n"
+ self."foo"()
+.end
+
+.namespace ['Child']
+.sub foo :method
+ print "Child foo\n"
+ .local pmc s
+ s = new .Super, self
+ s."foo"()
+.end
+
+.namespace ['GrandChild']
+.sub foo :method
+ print "GrandChild foo\n"
+ .local pmc s
+ s = new .Super, self
+ s."foo"()
+.end
+
+CODE
+GrandChild foo
+Child foo
+Parent foo
+OUTPUT
+
+pir_output_is( <<'CODE', <<'OUTPUT', "super 3 - diamond" );
+.sub main :main
+ .local pmc o, p, c1, c2, i
+ p = newclass 'Parent'
+ c1 = subclass p, 'Child1'
+ c2 = subclass p, 'Child2'
+ i = subclass c1, 'Inbred'
+ addparent i, c2
+ o = new 'Inbred'
+ o."foo"()
+.end
+
+.namespace ['Parent']
+.sub foo :method
+ print "Parent foo\n"
+ self."foo"()
+.end
+
+.namespace ['Child1']
+.sub foo :method
+ print "Child1 foo\n"
+ .local pmc s
+ s = new .Super, self
+ s."foo"()
+.end
+
+.namespace ['Child2']
+.sub foo :method
+ print "Child2 foo\n"
+ .local pmc s
+ s = new .Super, self
+ s."foo"()
+.end
+
+.namespace ['Inbred']
+.sub foo :method
+ print "Inbred foo\n"
+ .local pmc s
+ s = new .Super, self
+ s."foo"()
+.end
+
+CODE
+Inbred foo
+Child1 foo
+Child2 foo
+Parent foo
+OUTPUT
+
+
+
pir_output_is( <<'CODE', <<'OUTPUT', "delegate keyed_int" );
.sub main :main
.local pmc cl, o