[svn:parrot] r41254 - in trunk: src/pmc t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Sun Sep 13 19:34:05 UTC 2009
Author: NotFound
Date: Sun Sep 13 19:34:03 2009
New Revision: 41254
URL: https://trac.parrot.org/parrot/changeset/41254
Log:
[pmc] applied patch from TT #1005 for Hash is_equal, flh++
Modified:
trunk/src/pmc/hash.pmc
trunk/t/pmc/hash.t
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Sun Sep 13 18:44:48 2009 (r41253)
+++ trunk/src/pmc/hash.pmc Sun Sep 13 19:34:03 2009 (r41254)
@@ -1330,7 +1330,6 @@
for (j = 0; j < n; ++j) {
STRING * const key = VTABLE_shift_string(INTERP, iter);
PMC *item1, *item2;
- INTVAL result;
if (!VTABLE_exists_keyed_str(INTERP, value, key))
return 0;
@@ -1341,9 +1340,7 @@
if (item1 == item2)
continue;
- Parrot_mmd_multi_dispatch_from_c_args(INTERP, "is_equal",
- "PP->I", item1, item2, &result);
- if (!result)
+ if (!VTABLE_is_equal(INTERP, item1, item2))
return 0;
}
Modified: trunk/t/pmc/hash.t
==============================================================================
--- trunk/t/pmc/hash.t Sun Sep 13 18:44:48 2009 (r41253)
+++ trunk/t/pmc/hash.t Sun Sep 13 19:34:03 2009 (r41254)
@@ -23,7 +23,7 @@
.include 'except_types.pasm'
.include 'datatypes.pasm'
- plan(161)
+ plan(165)
initial_hash_tests()
more_than_one_hash()
@@ -71,6 +71,7 @@
integer_keys()
value_types_convertion()
elements_in_hash()
+ equality_tests()
.end
.sub initial_hash_tests
@@ -1369,6 +1370,40 @@
.end
+.sub 'equality_tests'
+ .local pmc hash1, hash2, hash3, hash4, hash5
+ hash1 = new ['Hash']
+ hash2 = new ['Hash']
+ hash3 = new ['Hash']
+ hash4 = new ['Hash']
+
+ hash1['one'] = "Hello Parrot!"
+ hash1['two'] = 1664
+ hash1['three'] = 2.718
+
+ hash2['ONE'] = "Hello Parrot!"
+ hash2['TWO'] = 1664
+ hash2['THREE'] = 2.718
+
+ $P0 = box "Hello Parrot!"
+ hash3['one'] = $P0
+ $P0 = box 1664
+ hash3['two'] = $P0
+ $P0 = box 2.718
+ hash3['three'] = $P0
+
+ hash4['one'] = "Goodbye Parrot!"
+ hash4['two'] = 1664
+ hash4['three'] = 2.718
+
+ hash5 = clone hash1
+
+ isnt(hash1, hash2, 'Hashes with different keys')
+ is(hash1, hash3, 'Equal hashes, physically disjoint')
+ isnt(hash1, hash4, 'Different hash values')
+ is(hash1, hash5, 'Clones are equal')
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
More information about the parrot-commits
mailing list