Ticket #1005: hash_vtable_equal.patch

File hash_vtable_equal.patch, 2.2 KB (added by flh, 12 years ago)
  • src/pmc/hash.pmc

     
    13301330        for (j = 0; j < n; ++j) { 
    13311331            STRING * const key = VTABLE_shift_string(INTERP, iter); 
    13321332            PMC           *item1, *item2; 
    1333             INTVAL         result; 
    13341333 
    13351334            if (!VTABLE_exists_keyed_str(INTERP, value, key)) 
    13361335                return 0; 
     
    13411340            if (item1 == item2) 
    13421341                continue; 
    13431342 
    1344             Parrot_mmd_multi_dispatch_from_c_args(INTERP, "is_equal", 
    1345                 "PP->I", item1, item2, &result); 
    1346             if (!result) 
     1343            if (!VTABLE_is_equal(INTERP, item1, item2)) 
    13471344                return 0; 
    13481345        } 
    13491346 
  • t/pmc/hash.t

     
    2323    .include 'except_types.pasm' 
    2424    .include 'datatypes.pasm' 
    2525 
    26     plan(161) 
     26    plan(165) 
    2727 
    2828    initial_hash_tests() 
    2929    more_than_one_hash() 
     
    7171    integer_keys() 
    7272    value_types_convertion() 
    7373    elements_in_hash() 
     74    equality_tests() 
    7475.end 
    7576 
    7677.sub initial_hash_tests 
     
    13691370 
    13701371.end 
    13711372 
     1373.sub 'equality_tests' 
     1374    .local pmc hash1, hash2, hash3, hash4, hash5 
     1375    hash1 = new ['Hash'] 
     1376    hash2 = new ['Hash'] 
     1377    hash3 = new ['Hash'] 
     1378    hash4 = new ['Hash'] 
     1379 
     1380    hash1['one'] = "Hello Parrot!" 
     1381    hash1['two'] = 1664 
     1382    hash1['three'] = 2.718 
     1383 
     1384    hash2['ONE'] = "Hello Parrot!" 
     1385    hash2['TWO'] = 1664 
     1386    hash2['THREE'] = 2.718 
     1387 
     1388    $P0 = box "Hello Parrot!" 
     1389    hash3['one'] = $P0 
     1390    $P0 = box 1664 
     1391    hash3['two'] = $P0 
     1392    $P0 = box 2.718 
     1393    hash3['three'] = $P0 
     1394 
     1395    hash4['one'] = "Goodbye Parrot!" 
     1396    hash4['two'] = 1664 
     1397    hash4['three'] = 2.718 
     1398 
     1399    hash5 = clone hash1 
     1400 
     1401    isnt(hash1, hash2, 'Hashes with different keys') 
     1402    is(hash1, hash3, 'Equal hashes, physically disjoint') 
     1403    isnt(hash1, hash4, 'Different hash values') 
     1404    is(hash1, hash5, 'Clones are equal') 
     1405.end 
     1406 
    13721407# Local Variables: 
    13731408#   mode: pir 
    13741409#   fill-column: 100