From edc231e2a90416ee23ded7768700cf1de23eb69d Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Tue, 19 Jun 2012 15:23:03 +0000 Subject: [PATCH] Fix return values for Harmony map and set operations. R=rossberg@chromium.org BUG=chromium:132741,chromium:132742 TEST=mjsunit/harmony/collections Review URL: https://chromiumcodereview.appspot.com/10573011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11869 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/collection.js | 7 ++++++- src/runtime.cc | 8 ++++---- test/mjsunit/harmony/collections.js | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/collection.js b/src/collection.js index 75fe3d5..9ca0aae 100644 --- a/src/collection.js +++ b/src/collection.js @@ -79,7 +79,12 @@ function SetDelete(key) { if (IS_UNDEFINED(key)) { key = undefined_sentinel; } - return %SetDelete(this, key); + if (%SetHas(this, key)) { + %SetDelete(this, key); + return true; + } else { + return false; + } } diff --git a/src/runtime.cc b/src/runtime.cc index 5bc1560..7b23306 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -754,7 +754,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { Handle table(ObjectHashSet::cast(holder->table())); table = ObjectHashSetAdd(table, key); holder->set_table(*table); - return isolate->heap()->undefined_symbol(); + return isolate->heap()->undefined_value(); } @@ -776,7 +776,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { Handle table(ObjectHashSet::cast(holder->table())); table = ObjectHashSetRemove(table, key); holder->set_table(*table); - return isolate->heap()->undefined_symbol(); + return isolate->heap()->undefined_value(); } @@ -808,7 +808,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { Handle table(ObjectHashTable::cast(holder->table())); Handle new_table = PutIntoObjectHashTable(table, key, value); holder->set_table(*new_table); - return *value; + return isolate->heap()->undefined_value(); } @@ -842,7 +842,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { Handle table(ObjectHashTable::cast(weakmap->table())); Handle new_table = PutIntoObjectHashTable(table, key, value); weakmap->set_table(*new_table); - return *value; + return isolate->heap()->undefined_value(); } diff --git a/test/mjsunit/harmony/collections.js b/test/mjsunit/harmony/collections.js index 412e6f1..95504bc 100644 --- a/test/mjsunit/harmony/collections.js +++ b/test/mjsunit/harmony/collections.js @@ -65,9 +65,11 @@ TestInvalidCalls(new WeakMap); // Test expected behavior for Sets function TestSet(set, key) { assertFalse(set.has(key)); - set.add(key); + assertSame(undefined, set.add(key)); assertTrue(set.has(key)); - set.delete(key); + assertTrue(set.delete(key)); + assertFalse(set.has(key)); + assertFalse(set.delete(key)); assertFalse(set.has(key)); } function TestSetBehavior(set) { @@ -87,7 +89,7 @@ TestSetBehavior(new Set); // Test expected mapping behavior for Maps and WeakMaps function TestMapping(map, key, value) { - map.set(key, value); + assertSame(undefined, map.set(key, value)); assertSame(value, map.get(key)); } function TestMapBehavior1(m) { -- 2.7.4