Index: t/oo/vtableoverride.t =================================================================== --- t/oo/vtableoverride.t (revision 35734) +++ t/oo/vtableoverride.t (working copy) @@ -18,8 +18,13 @@ .sub main :main .include 'test_more.pir' - plan(4) + plan(11) + newclass_tests() + subclass_tests() +.end + +.sub 'newclass_tests' $P1 = new 'MyObject' # Test get_string @@ -28,7 +33,15 @@ $P0 = getattribute $P1, "message" $S0 = $P0 is($S0, "[MyObject]", "attribute sideeffect of get_string") - + + # Test does + $I0 = does $P1, 'this_dress_make...' + is ($I0, 1, "check first does, ok") + $I0 = does $P1, 'a_body_good' + is ($I0, 1, "check second does, ok") + $I0 = does $P1, 'it_better' + is ($I0, 0, "no it doesn't") + # Test morph (doesn't actually perform a morph) morph $P1, "String" $P0 = getattribute $P1, "message" @@ -41,6 +54,22 @@ is($S0, "Morphing [MyObject] to type Integer", "Morph VTABLE override 1") .end +.sub 'subclass_tests' + $P1 = new 'MySubObject' + + # Test does, same as newclass. + $I0 = does $P1, 'this_dress_make...' + is ($I0, 1, "check first does, ok") + $I0 = does $P1, 'a_body_good' + is ($I0, 1, "check second does, ok") + $I0 = does $P1, 'it_better' + is ($I0, 0, "no it doesn't") + # Also verify we does what our parent does + $I0 = does $P1, 'array' + is ($I0, 1, "inherited does") +.end + + .namespace [ 'MyObject' ] .sub '__onload' :anon :init @@ -66,8 +95,35 @@ $P0 = box $S1 setattribute self, "message", $P0 .end - + +.sub 'does' :vtable + .param string query + if query == 'this_dress_make...' goto yes + if query == 'a_body_good' goto yes + .return(0) +yes: + .return (1) +.end +.namespace [ 'MySubObject' ] + +.sub '__onload' :anon :init + $P1 = get_class 'ResizablePMCArray' + $P0 = subclass $P1, 'MySubObject' +.end + +.sub 'does' :vtable + .param string query + if query == 'this_dress_make...' goto yes + if query == 'a_body_good' goto yes + .return(0) +yes: + .return (1) +.end + + + + # Local Variables: # mode: pir # fill-column: 100