Author: jonathan
Date: Sun Apr 15 14:46:20 2007
New Revision: 18231

Modified:
   trunk/src/pmc/class.pmc
   trunk/t/pmc/class.t

Log:
[PDD15]: Make name method on Class PMC also set the namespace, as specified. 
Test for this.

Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc     (original)
+++ trunk/src/pmc/class.pmc     Sun Apr 15 14:46:20 2007
@@ -760,8 +760,12 @@
         STRING *ret_name = NULL;
 
         if (got_name) {
-            /* Set class name. */
-            class->name = name;
+            /* We'll build a hash just containing the name, then give this to
+             * init_class_from_hash - saves some code duplication. */
+            PMC *naming_hash = pmc_new(interp, enum_class_Hash);
+            VTABLE_set_string_keyed_str(interp, naming_hash,
+                CONST_STRING(interp, "name"), name);
+            init_class_from_hash(interp, SELF, naming_hash);
         }
 
         ret_name = class->name;

Modified: trunk/t/pmc/class.t
==============================================================================
--- trunk/t/pmc/class.t (original)
+++ trunk/t/pmc/class.t Sun Apr 15 14:46:20 2007
@@ -83,11 +83,17 @@
   ok_3:
     say 'ok 3 - name() with too many args fails'
 
+    $P1 = $P0.'namespace'()
+    if $P1 == 'Alex' goto ok_4
+    print 'not '
+ok_4:
+    say 'ok 4 - name() with args sets namespace too'
 .end
 CODE
 ok 1 - name() with no args returns class name, which is empty at first
 ok 2 - name() with args sets class name
 ok 3 - name() with too many args fails
+ok 4 - name() with args sets namespace too
 OUT
 
 # L<PDD15/Class PMC API/=item new>

Reply via email to