Revision: 11869
Author: [email protected]
Date: Tue Jun 19 08:23:03 2012
Log: Fix return values for Harmony map and set operations.
[email protected]
BUG=chromium:132741,chromium:132742
TEST=mjsunit/harmony/collections
Review URL: https://chromiumcodereview.appspot.com/10573011
http://code.google.com/p/v8/source/detail?r=11869
Modified:
/branches/bleeding_edge/src/collection.js
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/harmony/collections.js
=======================================
--- /branches/bleeding_edge/src/collection.js Mon Feb 20 05:48:24 2012
+++ /branches/bleeding_edge/src/collection.js Tue Jun 19 08:23:03 2012
@@ -79,7 +79,12 @@
if (IS_UNDEFINED(key)) {
key = undefined_sentinel;
}
- return %SetDelete(this, key);
+ if (%SetHas(this, key)) {
+ %SetDelete(this, key);
+ return true;
+ } else {
+ return false;
+ }
}
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Jun 19 07:29:48 2012
+++ /branches/bleeding_edge/src/runtime.cc Tue Jun 19 08:23:03 2012
@@ -754,7 +754,7 @@
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 @@
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 @@
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 @@
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();
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/collections.js Thu Jan 5
04:55:06 2012
+++ /branches/bleeding_edge/test/mjsunit/harmony/collections.js Tue Jun 19
08:23:03 2012
@@ -65,10 +65,12 @@
// 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) {
for (var i = 0; i < 20; i++) {
@@ -87,7 +89,7 @@
// 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