[svn:parrot] r45360 - in trunk: src/pmc t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Mar 31 19:47:07 UTC 2010


Author: NotFound
Date: Wed Mar 31 19:47:07 2010
New Revision: 45360
URL: https://trac.parrot.org/parrot/changeset/45360

Log:
fix FPA.init_int and add a test for it

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

Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc	Wed Mar 31 18:27:14 2010	(r45359)
+++ trunk/src/pmc/fixedpmcarray.pmc	Wed Mar 31 19:47:07 2010	(r45360)
@@ -91,20 +91,13 @@
 */
 
     VTABLE void init_int(INTVAL size) {
-        PMC **data;
-        int i;
-
         if (size < 0)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                     _("FixedPMCArray: Cannot set array size to a negative number (%d)"), size);
 
-        SET_ATTR_size(INTERP, SELF, size);
-        data           = mem_gc_allocate_n_typed(INTERP, size, PMC *);
+        SELF.set_integer_native(size);
 
-        for (i = 0; i < size; i++)
-            data[i] = PMCNULL;
-
-        PObj_custom_destroy_SET(SELF);
+        PObj_custom_mark_destroy_SETALL(SELF);
     }
 
 /*

Modified: trunk/t/pmc/fixedpmcarray.t
==============================================================================
--- trunk/t/pmc/fixedpmcarray.t	Wed Mar 31 18:27:14 2010	(r45359)
+++ trunk/t/pmc/fixedpmcarray.t	Wed Mar 31 19:47:07 2010	(r45360)
@@ -19,7 +19,7 @@
 
 .sub main :main
     .include 'test_more.pir'
-    plan(82)
+    plan(83)
     test_setting_array_size()
     test_assign_from_another()
     test_assign_self()
@@ -678,6 +678,11 @@
 
     $I0 = $P0
     is($I0, 10, "New style init creates the correct # of elements for a key constant")
+
+    $P1 = new 'Integer'
+    $P0[9] = $P1
+    $P2 = $P0[9]
+    is($P2, $P1, 'New style init creates the array')
 .end
 
 .sub test_invalid_init_tt1509


More information about the parrot-commits mailing list