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

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sun Sep 13 18:44:50 UTC 2009


Author: NotFound
Date: Sun Sep 13 18:44:48 2009
New Revision: 41253
URL: https://trac.parrot.org/parrot/changeset/41253

Log:
[pmc] applied patch from TT #1005 (flh++) with test for RPA and modified FPA and RPA to inherit is_equal vtable function

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

Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc	Sun Sep 13 16:58:01 2009	(r41252)
+++ trunk/src/pmc/fixedpmcarray.pmc	Sun Sep 13 18:44:48 2009	(r41253)
@@ -594,7 +594,7 @@
     VTABLE INTVAL is_equal(PMC *value) {
         INTVAL j, n;
 
-        if (value->vtable->base_type != enum_class_FixedPMCArray)
+        if (value->vtable->base_type != SELF->vtable->base_type)
             return 0;
 
         n = SELF.elements();

Modified: trunk/src/pmc/resizablepmcarray.pmc
==============================================================================
--- trunk/src/pmc/resizablepmcarray.pmc	Sun Sep 13 16:58:01 2009	(r41252)
+++ trunk/src/pmc/resizablepmcarray.pmc	Sun Sep 13 18:44:48 2009	(r41253)
@@ -597,45 +597,6 @@
 
 /*
 
-=item C<INTVAL is_equal(PMC *value)>
-
-The C<==> operation. Compares two array to hold equal elements.
-
-=cut
-
-*/
-
-    VTABLE INTVAL is_equal(PMC *value) {
-        INTVAL j, n;
-
-        if (value->vtable->base_type != enum_class_ResizablePMCArray)
-            return 0;
-
-        n = SELF.elements();
-
-        if (VTABLE_elements(INTERP, value) != n)
-            return 0;
-
-        for (j = 0; j < n; ++j) {
-            PMC *item1 = SELF.get_pmc_keyed_int(j);
-            PMC *item2 = VTABLE_get_pmc_keyed_int(INTERP, value, j);
-            INTVAL result;
-
-            if (item1 == item2)
-                continue;
-
-            Parrot_mmd_multi_dispatch_from_c_args(INTERP,
-                    "is_equal", "PP->I", item1, item2, &result);
-
-            if (!result)
-                return 0;
-        }
-
-        return 1;
-    }
-
-/*
-
 =item METHOD append(PMC *other)
 
 Append the other array to this array.

Modified: trunk/t/pmc/resizablepmcarray.t
==============================================================================
--- trunk/t/pmc/resizablepmcarray.t	Sun Sep 13 16:58:01 2009	(r41252)
+++ trunk/t/pmc/resizablepmcarray.t	Sun Sep 13 18:44:48 2009	(r41253)
@@ -21,7 +21,7 @@
     .include 'fp_equality.pasm'
     .include 'test_more.pir'
 
-    plan(122)
+    plan(125)
 
     resize_tests()
     negative_array_size()
@@ -49,6 +49,7 @@
     method_forms_of_unshift_etc()
     sort_with_broken_cmp()
     addr_tests()
+    equality_tests()
 .end
 
 
@@ -942,6 +943,33 @@
     is($I0, $I1, 'Adding element to RPA keeps same addr')
 .end
 
+.sub 'equality_tests'
+    .local pmc array1, array2, array3, array4
+    array1 = new ['ResizablePMCArray']
+    array2 = new ['ResizablePMCArray']
+    array3 = new ['ResizablePMCArray']
+
+    array1[0] = "Hello Parrot!"
+    array1[1] = 1664
+    array1[2] = 2.718
+
+    $P0 = box "Hello Parrot!"
+    array2[0] = $P0
+    $P0 = box 1664
+    array2[1] = $P0
+    $P0 = box 2.718
+    array2[2] = $P0
+
+    array3[0] = "Goodbye Parrot!"
+    array3[1] = 1664
+    array3[2] = 2.718
+
+    array4 = clone array1
+
+    is(array1, array2, 'Physically disjoint, but equal arrays')
+    is(array1, array4, 'Clones are equal')
+    isnt(array1, array3, 'Different arrays')
+.end
 
 # don't forget to change the test plan
 


More information about the parrot-commits mailing list