throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.get', this]);
}
- if (!IS_SPEC_OBJECT(key)) {
+ if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
}
return %WeakMapGet(this, key);
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.set', this]);
}
- if (!IS_SPEC_OBJECT(key)) {
+ if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
}
return %WeakMapSet(this, key, value);
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.has', this]);
}
- if (!IS_SPEC_OBJECT(key)) {
+ if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
}
return %WeakMapHas(this, key);
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.delete', this]);
}
- if (!IS_SPEC_OBJECT(key)) {
+ if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
}
return %WeakMapDelete(this, key);
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<Object> lookup(table->Lookup(*key), isolate);
return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup;
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<Object> lookup(table->Lookup(*key), isolate);
return isolate->heap()->ToBoolean(!lookup->IsTheHole());
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<Object> lookup(table->Lookup(*key), isolate);
Handle<ObjectHashTable> new_table =
HandleScope scope(isolate);
ASSERT(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
Handle<Object> value(args[2], isolate);
Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
TestSet()
-function TestMap() {
+function TestCollections() {
+ var set = new Set
var map = new Map
+ var weakmap = new WeakMap
for (var i in symbols) {
+ set.add(symbols[i])
map.set(symbols[i], i)
+ weakmap.set(symbols[i], i)
}
+ assertEquals(symbols.length, set.size)
+ assertEquals(symbols.length, map.size)
for (var i in symbols) {
+ assertTrue(set.has(symbols[i]))
assertTrue(map.has(symbols[i]))
+ assertTrue(weakmap.has(symbols[i]))
assertEquals(i, map.get(symbols[i]))
+ assertEquals(i, weakmap.get(symbols[i]))
}
+ for (var i in symbols) {
+ assertTrue(set.delete(symbols[i]))
+ assertTrue(map.delete(symbols[i]))
+ assertTrue(weakmap.delete(symbols[i]))
+ }
+ assertEquals(0, set.size)
+ assertEquals(0, map.size)
}
-TestMap()
+TestCollections()