cvsuser     04/02/27 00:47:41

  Modified:    t/pmc    objects.t
  Log:
  update objects_23, fix and more comments
  
  Revision  Changes    Path
  1.27      +32 -24    parrot/t/pmc/objects.t
  
  Index: objects.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/objects.t,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -r1.26 -r1.27
  --- objects.t 26 Feb 2004 17:10:31 -0000      1.26
  +++ objects.t 27 Feb 2004 08:47:41 -0000      1.27
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: objects.t,v 1.26 2004/02/26 17:10:31 leo Exp $
  +# $Id: objects.t,v 1.27 2004/02/27 08:47:41 leo Exp $
   
   =head1 NAME
   
  @@ -535,14 +535,19 @@
   
   output_is(<<'CODE', <<'OUTPUT', "attribute values and subclassing 2");
       newclass P1, "Foo"
  -    # must add attributes before object instantion
  -    addattribute P1, "i"
  -    addattribute P1, "j"
  +    # must add attributes before object instantiation
  +    addattribute P1, ".i"
  +    addattribute P1, ".j"
   
  -    newclass P2, "Bar"               # or subclass P2, P1, "Bar" ???
  -    addattribute P2, "k"
  -    addattribute P2, "l"
  -    addparent P2, P1
  +    subclass P2, P1, "Bar"
  +    addattribute P2, ".k"
  +    addattribute P2, ".l"
  +
  +    # subclass is prefered for the SI case over
  +    #   newclass P2, "Bar"
  +    #   addattrib ...
  +    #   addparent P2, P1
  +    # which is suitable for adding multiple parents to one class
   
       # instantiate a Bar object
       find_type I1, "Bar"
  @@ -550,40 +555,43 @@
   
       classoffset I3, P3, "Foo"   # The parent class
       # print I3                  # don't assume anything about this offset
  -    # print "\n"
  -
  +    # print "\n"             # ' for vim
   
  -    set I0, I3                       # is this always the first attribute?
  +    set I0, I3                       # access Foo attribs, remember offset
   
       new P10, .PerlString     # set attribute values
  -    set P10, "i\n"
  -    setattribute P3, I0, P10
  -    inc I0
  +    set P10, "i\n"           # attribute slots have reference semantics
  +    setattribute P3, I0, P10 # so always put new PMCs in
  +                                # if you have unique values
  +    inc I0                   # next attribute
       new P10, .PerlString
       set P10, "j\n"
       setattribute P3, I0, P10
  -    inc I0                   # is that safe to assume
  +
  +    classoffset I4, P3, "Bar"   # set Bar attribs
  +    set I1, I4                       # dup offset for retrieval again
  +
       new P10, .PerlString
       set P10, "k\n"
  -    setattribute P3, I0, P10
  -    inc I0
  +    setattribute P3, I1, P10
  +    inc I1
       new P10, .PerlString
       set P10, "l\n"
  -    setattribute P3, I0, P10
  +    setattribute P3, I1, P10
   
  -    getattribute P11, P3, I3
  +    getattribute P11, P3, I3 # retrieve attribs
       print P11
       inc I3
       getattribute P11, P3, I3
       print P11
  -    inc I3
  -    getattribute P11, P3, I3
  +
  +    getattribute P11, P3, I4
       print P11
  -    inc I3
  -    getattribute P11, P3, I3
  +    inc I4
  +    getattribute P11, P3, I4
       print P11
   
  -    classname S0, P3
  +    classname S0, P3         # verify classname is still ok
       print S0
       print "\n"
       end
  
  
  

Reply via email to