Index: t/pmc/objects.t =================================================================== --- t/pmc/objects.t (revision 11276) +++ t/pmc/objects.t (working copy) @@ -6,7 +6,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 62; +use Parrot::Test tests => 66; =head1 NAME @@ -1916,3 +1916,191 @@ 10 20 OUTPUT + +my $foo_methods = <<'FOO_METHODS'; +.sub foo_slot1 :method + classoffset $I33, self, "User::Foo" + add $I34, $I33, 0 + getattribute $P35, self, $I34 + .return ($P35) +.end +.sub _set_foo_slot1 :method + .param pmc new_value + classoffset $I33, self, "User::Foo" + add $I34, $I33, 0 + setattribute self, $I34, new_value + .return (new_value) +.end +.sub foo_slot2 :method + classoffset $I33, self, "User::Foo" + add $I34, $I33, 1 + getattribute $P35, self, $I34 + .return ($P35) +.end +.sub _set_foo_slot2 :method + .param pmc new_value + classoffset $I33, self, "User::Foo" + add $I34, $I33, 1 + setattribute self, $I34, new_value + .return (new_value) +.end +FOO_METHODS + +my $foo_class = <<'FOO_CLASS'."\n".$foo_methods; +## this uses a 'BUILD' property to define the initializer. +.namespace ["User::Foo"] +.sub Foo_onload + newclass $P0, "User::Foo" + addattribute $P0, "SLOT1" + addattribute $P0, "SLOT2" + $P1 = new "String" + $P1 = 'build_Foo' + setprop $P0, 'BUILD', $P1 +.end +.sub build_Foo :method + .param pmc hash + $S0 = typeof hash + print "[hash arg isa " + print $S0 + print "]\n" + defined $I32, hash + unless $I32 goto L0 + classoffset $I33, self, "User::Foo" + $P34 = hash["SLOT1"] + setattribute self, $I33, $P34 + inc $I33 + $P34 = hash["SLOT2"] + setattribute self, $I33, $P34 +L0: + .return (self) +.end +FOO_CLASS + +pir_output_is(<