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
parent a760b82c
...@@ -79,7 +79,12 @@ function SetDelete(key) { ...@@ -79,7 +79,12 @@ function SetDelete(key) {
if (IS_UNDEFINED(key)) { if (IS_UNDEFINED(key)) {
key = undefined_sentinel; key = undefined_sentinel;
} }
return %SetDelete(this, key); if (%SetHas(this, key)) {
%SetDelete(this, key);
return true;
} else {
return false;
}
} }
......
...@@ -754,7 +754,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { ...@@ -754,7 +754,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) {
Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
table = ObjectHashSetAdd(table, key); table = ObjectHashSetAdd(table, key);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_symbol(); return isolate->heap()->undefined_value();
} }
...@@ -776,7 +776,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { ...@@ -776,7 +776,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) {
Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
table = ObjectHashSetRemove(table, key); table = ObjectHashSetRemove(table, key);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_symbol(); return isolate->heap()->undefined_value();
} }
...@@ -808,7 +808,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { ...@@ -808,7 +808,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) {
Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
holder->set_table(*new_table); holder->set_table(*new_table);
return *value; return isolate->heap()->undefined_value();
} }
...@@ -842,7 +842,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { ...@@ -842,7 +842,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) {
Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
weakmap->set_table(*new_table); weakmap->set_table(*new_table);
return *value; return isolate->heap()->undefined_value();
} }
......
...@@ -65,9 +65,11 @@ TestInvalidCalls(new WeakMap); ...@@ -65,9 +65,11 @@ TestInvalidCalls(new WeakMap);
// Test expected behavior for Sets // Test expected behavior for Sets
function TestSet(set, key) { function TestSet(set, key) {
assertFalse(set.has(key)); assertFalse(set.has(key));
set.add(key); assertSame(undefined, set.add(key));
assertTrue(set.has(key)); assertTrue(set.has(key));
set.delete(key); assertTrue(set.delete(key));
assertFalse(set.has(key));
assertFalse(set.delete(key));
assertFalse(set.has(key)); assertFalse(set.has(key));
} }
function TestSetBehavior(set) { function TestSetBehavior(set) {
...@@ -87,7 +89,7 @@ TestSetBehavior(new Set); ...@@ -87,7 +89,7 @@ TestSetBehavior(new Set);
// Test expected mapping behavior for Maps and WeakMaps // Test expected mapping behavior for Maps and WeakMaps
function TestMapping(map, key, value) { function TestMapping(map, key, value) {
map.set(key, value); assertSame(undefined, map.set(key, value));
assertSame(value, map.get(key)); assertSame(value, map.get(key));
} }
function TestMapBehavior1(m) { function TestMapBehavior1(m) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment