Reviewers: rossberg,
Description:
Fix return values for Harmony map and set operations.
[email protected]
BUG=chromium:132741,chromium:132742
TEST=mjsunit/harmony/collections
Please review this at https://chromiumcodereview.appspot.com/10573011/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/collection.js
M src/runtime.cc
M test/mjsunit/harmony/collections.js
Index: src/collection.js
diff --git a/src/collection.js b/src/collection.js
index
75fe3d541db902ba539aada77fc601c7f5ae4821..9ca0aae60a18fcf39ca2f035bed2ce6cdd267c81
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;
+ }
}
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
5bc15604c173dbee2210a94fadb41f28b380e3c3..7b233063c694542bd0ba46b6f842acb988e7c51f
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -754,7 +754,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) {
Handle<ObjectHashSet> 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<ObjectHashSet> 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<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
Handle<ObjectHashTable> 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<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key,
value);
weakmap->set_table(*new_table);
- return *value;
+ return isolate->heap()->undefined_value();
}
Index: test/mjsunit/harmony/collections.js
diff --git a/test/mjsunit/harmony/collections.js
b/test/mjsunit/harmony/collections.js
index
412e6f14c32bd1d3b933fde22da22f3400241c5b..95504bc76ce9dfc94a4e434a029d63150bf69a4a
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) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev