Ticket #1005: rpa_vtable_equal.patch

File rpa_vtable_equal.patch, 2.0 KB (added by flh, 12 years ago)
  • src/pmc/resizablepmcarray.pmc

     
    619619        for (j = 0; j < n; ++j) { 
    620620            PMC *item1 = SELF.get_pmc_keyed_int(j); 
    621621            PMC *item2 = VTABLE_get_pmc_keyed_int(INTERP, value, j); 
    622             INTVAL result; 
    623622 
    624623            if (item1 == item2) 
    625624                continue; 
    626625 
    627             Parrot_mmd_multi_dispatch_from_c_args(INTERP, 
    628                     "is_equal", "PP->I", item1, item2, &result); 
    629  
    630             if (!result) 
     626            if (!VTABLE_is_equal(INTERP, item1, item2)) 
    631627                return 0; 
    632628        } 
    633629 
  • t/pmc/resizablepmcarray.t

     
    2121    .include 'fp_equality.pasm' 
    2222    .include 'test_more.pir' 
    2323 
    24     plan(122) 
     24    plan(125) 
    2525 
    2626    resize_tests() 
    2727    negative_array_size() 
     
    4949    method_forms_of_unshift_etc() 
    5050    sort_with_broken_cmp() 
    5151    addr_tests() 
     52    equality_tests() 
    5253.end 
    5354 
    5455 
     
    942943    is($I0, $I1, 'Adding element to RPA keeps same addr') 
    943944.end 
    944945 
     946.sub 'equality_tests' 
     947    .local pmc array1, array2, array3, array4 
     948    array1 = new ['ResizablePMCArray'] 
     949    array2 = new ['ResizablePMCArray'] 
     950    array3 = new ['ResizablePMCArray'] 
    945951 
     952    array1[0] = "Hello Parrot!" 
     953    array1[1] = 1664 
     954    array1[2] = 2.718 
     955 
     956    $P0 = box "Hello Parrot!" 
     957    array2[0] = $P0 
     958    $P0 = box 1664 
     959    array2[1] = $P0 
     960    $P0 = box 2.718 
     961    array2[2] = $P0 
     962 
     963    array3[0] = "Goodbye Parrot!" 
     964    array3[1] = 1664 
     965    array3[2] = 2.718 
     966 
     967    array4 = clone array1 
     968 
     969    is(array1, array2, 'Physically disjoint, but equal arrays') 
     970    is(array1, array4, 'Clones are equal') 
     971    isnt(array1, array3, 'Different arrays') 
     972.end 
     973 
    946974# don't forget to change the test plan 
    947975 
    948976# Local Variables: