Ticket #1005: hash_vtable_equal.patch
File hash_vtable_equal.patch, 2.2 KB (added by flh, 12 years ago) |
---|
-
src/pmc/hash.pmc
1330 1330 for (j = 0; j < n; ++j) { 1331 1331 STRING * const key = VTABLE_shift_string(INTERP, iter); 1332 1332 PMC *item1, *item2; 1333 INTVAL result;1334 1333 1335 1334 if (!VTABLE_exists_keyed_str(INTERP, value, key)) 1336 1335 return 0; … … 1341 1340 if (item1 == item2) 1342 1341 continue; 1343 1342 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)) 1347 1344 return 0; 1348 1345 } 1349 1346 -
t/pmc/hash.t
23 23 .include 'except_types.pasm' 24 24 .include 'datatypes.pasm' 25 25 26 plan(16 1)26 plan(165) 27 27 28 28 initial_hash_tests() 29 29 more_than_one_hash() … … 71 71 integer_keys() 72 72 value_types_convertion() 73 73 elements_in_hash() 74 equality_tests() 74 75 .end 75 76 76 77 .sub initial_hash_tests … … 1369 1370 1370 1371 .end 1371 1372 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 1372 1407 # Local Variables: 1373 1408 # mode: pir 1374 1409 # fill-column: 100