Author: jonathan
Date: Tue Mar 27 17:06:46 2007
New Revision: 17797
Modified:
trunk/src/pmc/class.pmc
trunk/t/oo/mro-c3.t
trunk/t/pmc/class.t
Log:
[PDD15]: Fix bug in method finding. Parrot_PCCINVOKE fix means that C3 MRO
computation can now be tested. Happily, the tests pass, though we need a few
more to be sure the C3 implementation is totally correct. Add a new simple
multiple inheritance test. Untodo the C3 tests and those todo'd in class.t as a
result of being unable to compute an inheritance hierarchy.
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc (original)
+++ trunk/src/pmc/class.pmc Tue Mar 27 17:06:46 2007
@@ -648,6 +648,7 @@
if (VTABLE_exists_keyed_str(interp, class_info->methods, name)) {
/* Found it! */
found = VTABLE_get_pmc_keyed_str(interp, class_info->methods,
name);
+ break;
}
}
Modified: trunk/t/oo/mro-c3.t
==============================================================================
--- trunk/t/oo/mro-c3.t (original)
+++ trunk/t/oo/mro-c3.t Tue Mar 27 17:06:46 2007
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
=head1 NAME
@@ -22,7 +22,7 @@
=cut
-pir_output_is( <<'CODE', <<'OUT', 'single parent', todo => 'Parrot_PCCINVOKE
broken' );
+pir_output_is( <<'CODE', <<'OUT', 'single parent' );
.sub 'test' :main
.local pmc A, B
@@ -52,7 +52,7 @@
Method from A called
OUT
-pir_output_is( <<'CODE', <<'OUT', 'grandparent', todo => 'Parrot_PCCINVOKE
broken' );
+pir_output_is( <<'CODE', <<'OUT', 'grandparent' );
.sub 'test' :main
.local pmc A, B, C
@@ -94,7 +94,49 @@
Method from A called
OUT
-pir_output_is( <<'CODE', <<'OUT', 'diamond inheritance', todo =>
'Parrot_PCCINVOKE broken' );
+pir_output_is( <<'CODE', <<'OUT', 'multiple inheritance' );
+.sub 'test' :main
+ .local pmc A, B, C
+
+ A = new .Class
+ $P0 = find_global 'testA'
+ A.'add_method'("foo", $P0)
+ A.'add_method'("bar", $P0)
+ A.'add_method'("baz", $P0)
+
+ B = new .Class
+ $P0 = find_global 'testB'
+ B.'add_method'("foo", $P0)
+ B.'add_method'("bar", $P0)
+
+ C = new .Class
+ C.'add_parent'(B)
+ C.'add_parent'(A)
+ $P0 = find_global 'testC'
+ C.'add_method'("foo", $P0)
+
+ $P0 = C.'new'()
+ $P0.foo()
+ $P0.bar()
+ $P0.baz()
+.end
+
+.sub testA :method
+ print "Method from A called\n"
+.end
+.sub testB :method
+ print "Method from B called\n"
+.end
+.sub testC :method
+ print "Method from C called\n"
+.end
+CODE
+Method from C called
+Method from B called
+Method from A called
+OUT
+
+pir_output_is( <<'CODE', <<'OUT', 'diamond inheritance' );
.sub 'test' :main
.local pmc A, B, C, D
@@ -110,17 +152,17 @@
$P0 = find_global 'testB'
B.'add_method'("foo", $P0)
B.'add_method'("bar", $P0)
+ B.'add_method'("baz", $P0)
C = new .Class
C.'add_parent'(A)
$P0 = find_global 'testC'
C.'add_method'("foo", $P0)
C.'add_method'("bar", $P0)
- B.'add_method'("baz", $P0)
D = new .Class
- D.'add_parent'(B)
D.'add_parent'(C)
+ D.'add_parent'(B)
$P0 = find_global 'testD'
D.'add_method'("foo", $P0)
Modified: trunk/t/pmc/class.t
==============================================================================
--- trunk/t/pmc/class.t (original)
+++ trunk/t/pmc/class.t Tue Mar 27 17:06:46 2007
@@ -91,7 +91,7 @@
OUT
# L<PDD15/Class PMC API/=item new>
-pir_output_is( <<'CODE', <<'OUT', 'new', todo => 'Parrot_PCCINVOKE broken' );
+pir_output_is( <<'CODE', <<'OUT', 'new' );
.sub 'test' :main
new $P0, .Class
$P1 = $P0.'new'()
@@ -195,7 +195,7 @@
## NOTE i think this belongs in the Object PMC tests
# L<PDD15/Class PMC API>
-pir_output_is( <<'CODE', <<'OUT', 'set_attr/get_attr VTABLE methods', todo =>
'Parrot_PCCINVOKE broken' );
+pir_output_is( <<'CODE', <<'OUT', 'set_attr/get_attr VTABLE methods' );
.sub 'test' :main
new $P0, .Class
$P0.'name'("Test")