mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
commit
f25d690a68
13
test/built-ins/WeakMap/constructor.js
Normal file
13
test/built-ins/WeakMap/constructor.js
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1
|
||||
description: >
|
||||
The WeakMap constructor is the %WeakMap% intrinsic object and the initial
|
||||
value of the WeakMap property of the global object.
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof WeakMap, 'function',
|
||||
'typeof WeakMap is "function"'
|
||||
);
|
31
test/built-ins/WeakMap/empty-iterable.js
Normal file
31
test/built-ins/WeakMap/empty-iterable.js
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
If the iterable argument is empty, return new WeakMap object.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
a. Let next be IteratorStep(iter).
|
||||
b. ReturnIfAbrupt(next).
|
||||
c. If next is false, return map.
|
||||
...
|
||||
---*/
|
||||
|
||||
var counter = 0;
|
||||
var set = WeakMap.prototype.set;
|
||||
WeakMap.prototype.set = function(value) {
|
||||
counter++;
|
||||
return set.call(this, value);
|
||||
};
|
||||
var map = new WeakMap([]);
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(map), WeakMap.prototype);
|
||||
assert(map instanceof WeakMap);
|
||||
assert.sameValue(
|
||||
counter, 0,
|
||||
'empty iterable does not call WeakMap.prototype.set'
|
||||
);
|
30
test/built-ins/WeakMap/get-set-method-failure.js
Normal file
30
test/built-ins/WeakMap/get-set-method-failure.js
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Return abrupt after getting `set` method.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
5. If iterable is not present, let iterable be undefined.
|
||||
6. If iterable is either undefined or null, let iter be undefined.
|
||||
7. Else,
|
||||
a. Let adder be Get(map, "set").
|
||||
b. ReturnIfAbrupt(adder).
|
||||
...
|
||||
---*/
|
||||
|
||||
Object.defineProperty(WeakMap.prototype, 'set', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
new WeakMap();
|
||||
new WeakMap(null);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap([]);
|
||||
});
|
19
test/built-ins/WeakMap/iterable-failure.js
Normal file
19
test/built-ins/WeakMap/iterable-failure.js
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
If the iterable argument is undefined, return new WeakMap object.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
7. Else,
|
||||
d. Let iter be GetIterator(iterable).
|
||||
e. ReturnIfAbrupt(iter).
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap({});
|
||||
});
|
37
test/built-ins/WeakMap/iterable.js
Normal file
37
test/built-ins/WeakMap/iterable.js
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Returns the new WeakMap adding the objects from the iterable parameter.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
|
||||
l. If status is an abrupt completion, return IteratorClose(iter, status).
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
var first = {};
|
||||
var second = {};
|
||||
var results = [];
|
||||
var set = WeakMap.prototype.set;
|
||||
WeakMap.prototype.set = function(key, value) {
|
||||
results.push({
|
||||
_this: this,
|
||||
key: key,
|
||||
value: value
|
||||
});
|
||||
return set.call(this, key, value);
|
||||
};
|
||||
var map = new WeakMap([[first, 42], [second, 43]]);
|
||||
|
||||
assert.sameValue(results.length, 2, 'Called WeakMap#set for each object');
|
||||
assert.sameValue(results[0].key, first, 'Adds object in order - first key');
|
||||
assert.sameValue(results[0].value, 42, 'Adds object in order - first value');
|
||||
assert.sameValue(results[0]._this, map, 'Adds object in order - this');
|
||||
assert.sameValue(results[1].key, second, 'Adds object in order - second key');
|
||||
assert.sameValue(results[1].value, 43, 'Adds object in order - second value');
|
||||
assert.sameValue(results[1]._this, map, 'Adds object in order - this');
|
37
test/built-ins/WeakMap/iterator-close-after-set-failure.js
Normal file
37
test/built-ins/WeakMap/iterator-close-after-set-failure.js
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Return IteratorClose(iter, status) if fail on adding value on constructing.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
|
||||
l. If status is an abrupt completion, return IteratorClose(iter, status).
|
||||
---*/
|
||||
|
||||
var count = 0;
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { value: [], done: false };
|
||||
},
|
||||
return: function() {
|
||||
count += 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
WeakMap.prototype.set = function() { throw new Test262Error(); };
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
|
||||
assert.sameValue(
|
||||
count, 1,
|
||||
'The iterator is closed when `WeakMap.prototype.set` throws an error.'
|
||||
);
|
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Closes iterator if item first entry completes abruptly.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
...
|
||||
d. Let nextItem be IteratorValue(next).
|
||||
...
|
||||
g. Let k be Get(nextItem, "0").
|
||||
h. If k is an abrupt completion, return IteratorClose(iter, k).
|
||||
...
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var count = 0;
|
||||
var item = ['foo', 'bar'];
|
||||
Object.defineProperty(item, 0, {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return {
|
||||
value: item,
|
||||
done: false
|
||||
};
|
||||
},
|
||||
return: function() {
|
||||
count++;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
|
||||
assert.sameValue(count, 1, 'The get error closed the iterator');
|
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Closes iterator if item second entry completes abruptly.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
...
|
||||
d. Let nextItem be IteratorValue(next).
|
||||
...
|
||||
i. Let v be Get(nextItem, "1").
|
||||
j. If v is an abrupt completion, return IteratorClose(iter, v).
|
||||
...
|
||||
features: [Symbol.iterator]
|
||||
---*/
|
||||
|
||||
var count = 0;
|
||||
var item = ['foo', 'bar'];
|
||||
Object.defineProperty(item, 1, {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return {
|
||||
value: item,
|
||||
done: false
|
||||
};
|
||||
},
|
||||
return: function() {
|
||||
count++;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
|
||||
assert.sameValue(count, 1, 'The get error closed the iterator');
|
@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Closes the iterator object after not object error on next item.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
...
|
||||
d. Let nextItem be IteratorValue(next).
|
||||
e. ReturnIfAbrupt(nextItem).
|
||||
f. If Type(nextItem) is not Object,
|
||||
i. Let error be Completion{[[type]]: throw, [[value]]: a newly created
|
||||
TypeError object, [[target]]:empty}.
|
||||
ii. Return IteratorClose(iter, error).
|
||||
features:
|
||||
- Symbol
|
||||
- Symbol.iterator
|
||||
---*/
|
||||
|
||||
var count = 0;
|
||||
var nextItem;
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return { value: nextItem, done: false };
|
||||
},
|
||||
return: function() {
|
||||
count += 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
nextItem = 1;
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 1);
|
||||
|
||||
nextItem = true;
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 2);
|
||||
|
||||
nextItem = '';
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
nextItem = null;
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 4);
|
||||
|
||||
nextItem = undefined;
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 5);
|
||||
|
||||
nextItem = Symbol('a');
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
||||
assert.sameValue(count, 6);
|
48
test/built-ins/WeakMap/iterator-items-are-not-object.js
Normal file
48
test/built-ins/WeakMap/iterator-items-are-not-object.js
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Throws a TypeError if iterable itens are not Objects.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
...
|
||||
d. Let nextItem be IteratorValue(next).
|
||||
e. ReturnIfAbrupt(nextItem).
|
||||
f. If Type(nextItem) is not Object,
|
||||
i. Let error be Completion{[[type]]: throw, [[value]]: a newly created
|
||||
TypeError object, [[target]]:empty}.
|
||||
ii. Return IteratorClose(iter, error).
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([1, 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap(['', 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([true, 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([null, 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([Symbol('a'), 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([undefined, 1]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([['a', 1], 2]);
|
||||
});
|
28
test/built-ins/WeakMap/iterator-next-failure.js
Normal file
28
test/built-ins/WeakMap/iterator-next-failure.js
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Return abrupt from next iterator step.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
a. Let next be IteratorStep(iter).
|
||||
b. ReturnIfAbrupt(next).
|
||||
...
|
||||
---*/
|
||||
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
34
test/built-ins/WeakMap/iterator-value-failure.js
Normal file
34
test/built-ins/WeakMap/iterator-value-failure.js
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
If the iterable argument is empty, return new WeakMap object.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
9. Repeat
|
||||
...
|
||||
d. Let nextItem be IteratorValue(next).
|
||||
e. ReturnIfAbrupt(nextItem).
|
||||
...
|
||||
---*/
|
||||
|
||||
var iterable = {};
|
||||
iterable[Symbol.iterator] = function() {
|
||||
return {
|
||||
next: function() {
|
||||
return {
|
||||
get value() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
done: false
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
new WeakMap(iterable);
|
||||
});
|
14
test/built-ins/WeakMap/length.js
Normal file
14
test/built-ins/WeakMap/length.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.2
|
||||
description: >
|
||||
The length property of the WeakMap constructor is 0.
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(WeakMap.length, 0, 'The value of `WeakMap.length` is `0`');
|
||||
|
||||
verifyNotEnumerable(WeakMap, 'length');
|
||||
verifyNotWritable(WeakMap, 'length');
|
||||
verifyConfigurable(WeakMap, 'length');
|
20
test/built-ins/WeakMap/name.js
Normal file
20
test/built-ins/WeakMap/name.js
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.name, 'WeakMap',
|
||||
'The value of `WeakMap.name` is "WeakMap"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap, 'name');
|
||||
verifyNotWritable(WeakMap, 'name');
|
||||
verifyConfigurable(WeakMap, 'name');
|
24
test/built-ins/WeakMap/no-iterable.js
Normal file
24
test/built-ins/WeakMap/no-iterable.js
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
If the iterable argument is undefined, return new WeakMap object.
|
||||
info: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
5. If iterable is not present, let iterable be undefined.
|
||||
6. If iterable is either undefined or null, let iter be undefined.
|
||||
...
|
||||
8. If iter is undefined, return map.
|
||||
...
|
||||
---*/
|
||||
|
||||
var a = new WeakMap();
|
||||
var b = new WeakMap(undefined);
|
||||
var c = new WeakMap(null);
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(a), WeakMap.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(b), WeakMap.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(c), WeakMap.prototype);
|
14
test/built-ins/WeakMap/properties-of-map-instances.js
Normal file
14
test/built-ins/WeakMap/properties-of-map-instances.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.4
|
||||
description: >
|
||||
WeakMap instances are ordinary objects that inherit properties from the
|
||||
WeakMap prototype.
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(new WeakMap()),
|
||||
WeakMap.prototype,
|
||||
'`Object.getPrototypeOf(new WeakMap())` returns `WeakMap.prototype`'
|
||||
);
|
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3
|
||||
description: >
|
||||
The WeakMap.prototype's prototype is Object.prototype.
|
||||
info: >
|
||||
23.3.3 Properties of the WeakMap Prototype Object
|
||||
|
||||
The WeakMap prototype object is the intrinsic object %WeakMapPrototype%. The
|
||||
value of the [[Prototype]] internal slot of the WeakMap prototype object is
|
||||
the intrinsic object %ObjectPrototype% (19.1.3). The WeakMap prototype object
|
||||
is an ordinary object. It does not have a [[WeakMapData]] internal slot.
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(WeakMap.prototype),
|
||||
Object.prototype,
|
||||
'`Object.getPrototypeOf(WeakMap.prototype)` returns `Object.prototype`'
|
||||
);
|
14
test/built-ins/WeakMap/prototype-of-weakmap.js
vendored
Normal file
14
test/built-ins/WeakMap/prototype-of-weakmap.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.2
|
||||
description: >
|
||||
The value of the [[Prototype]] internal slot of the WeakMap constructor is the
|
||||
intrinsic object %FunctionPrototype% (19.2.3).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(WeakMap),
|
||||
Function.prototype,
|
||||
'`Object.getPrototypeOf(WeakMap)` returns `Function.prototype`'
|
||||
);
|
26
test/built-ins/WeakMap/prototype/Symbol.toStringTag/property-descriptor.js
vendored
Normal file
26
test/built-ins/WeakMap/prototype/Symbol.toStringTag/property-descriptor.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.6
|
||||
description: "WeakMap#@@toStringTag value and writability"
|
||||
info: >
|
||||
WeakMap.prototype [ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the String value "WeakMap".
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||
[[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
var WeakMapProto = WeakMap.prototype;
|
||||
|
||||
assert.sameValue(
|
||||
WeakMapProto[Symbol.toStringTag],
|
||||
'WeakMap',
|
||||
'The value of WeakMap.prototype[Symbol.toStringTag] is "WeakMap"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMapProto, Symbol.toStringTag);
|
||||
verifyNotWritable(WeakMapProto, Symbol.toStringTag);
|
||||
verifyConfigurable(WeakMapProto, Symbol.toStringTag);
|
21
test/built-ins/WeakMap/prototype/constructor.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/constructor.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.1
|
||||
description: >
|
||||
WeakMap.prototype.constructor value and property descriptor
|
||||
info: >
|
||||
The initial value of WeakMap.prototype.constructor is the %WeakMap%
|
||||
intrinsic object.
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(WeakMap.prototype.constructor, WeakMap);
|
||||
assert.sameValue((new WeakMap()).constructor, WeakMap);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype, 'constructor');
|
||||
verifyWritable(WeakMap.prototype, 'constructor');
|
||||
verifyConfigurable(WeakMap.prototype, 'constructor');
|
29
test/built-ins/WeakMap/prototype/delete/delete-entry-initial-iterable.js
vendored
Normal file
29
test/built-ins/WeakMap/prototype/delete/delete-entry-initial-iterable.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Delete an entry from initial iterable.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
5. Let entries be the List that is the value of M’s [[WeakMapData]] internal
|
||||
slot.
|
||||
6. If Type(key) is not Object, return false.
|
||||
7. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, then
|
||||
i. Set p.[[key]] to empty.
|
||||
ii. Set p.[[value]] to empty.
|
||||
iii. Return true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var map = new WeakMap([[foo, 42]]);
|
||||
|
||||
var result = map.delete(foo);
|
||||
|
||||
assert.sameValue(map.has(foo), false);
|
||||
assert.sameValue(result, true, 'WeakMap#delete returns true');
|
31
test/built-ins/WeakMap/prototype/delete/delete-entry.js
vendored
Normal file
31
test/built-ins/WeakMap/prototype/delete/delete-entry.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Delete an entry.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
5. Let entries be the List that is the value of M’s [[WeakMapData]] internal
|
||||
slot.
|
||||
6. If Type(key) is not Object, return false.
|
||||
7. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, then
|
||||
i. Set p.[[key]] to empty.
|
||||
ii. Set p.[[value]] to empty.
|
||||
iii. Return true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var map = new WeakMap();
|
||||
|
||||
map.set(foo, 42);
|
||||
|
||||
var result = map.delete(foo);
|
||||
|
||||
assert.sameValue(map.has(foo), false);
|
||||
assert.sameValue(result, true, 'WeakMap#delete returns true');
|
23
test/built-ins/WeakMap/prototype/delete/delete.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/delete/delete.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
WeakMap.prototype.delete property descriptor
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof WeakMap.prototype.delete,
|
||||
'function',
|
||||
'typeof WeakMap.prototype.delete is "function"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype, 'delete');
|
||||
verifyWritable(WeakMap.prototype, 'delete');
|
||||
verifyConfigurable(WeakMap.prototype, 'delete');
|
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call([], {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call([], {});
|
||||
});
|
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Map]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(new Map(), {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(new Map(), {});
|
||||
});
|
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call({}, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call({}, {});
|
||||
});
|
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Set]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(new Set(), {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(new Set(), {});
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(WeakMap.prototype, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(WeakMap.prototype, {});
|
||||
});
|
22
test/built-ins/WeakMap/prototype/delete/length.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/delete/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
WeakMap.prototype.delete.length value and writability.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.delete.length, 1,
|
||||
'The value of WeakMap.prototype.delete.length is 1'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.delete, 'length');
|
||||
verifyNotWritable(WeakMap.prototype.delete, 'length');
|
||||
verifyConfigurable(WeakMap.prototype.delete, 'length');
|
22
test/built-ins/WeakMap/prototype/delete/name.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/delete/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
WeakMap.prototype.delete.name value and writability.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.delete.name, 'delete',
|
||||
'The value of WeakMap.prototype.delete.name is "delete"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.delete, 'name');
|
||||
verifyNotWritable(WeakMap.prototype.delete, 'name');
|
||||
verifyConfigurable(WeakMap.prototype.delete, 'name');
|
22
test/built-ins/WeakMap/prototype/delete/returns-false-value-is-not-object.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/delete/returns-false-value-is-not-object.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Return false if value is not an Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
5. If Type(key) is not Object, return false.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.sameValue(map.delete(1), false);
|
||||
assert.sameValue(map.delete(''), false);
|
||||
assert.sameValue(map.delete(NaN), false);
|
||||
assert.sameValue(map.delete(null), false);
|
||||
assert.sameValue(map.delete(undefined), false);
|
||||
assert.sameValue(map.delete(true), false);
|
||||
assert.sameValue(map.delete(Symbol()), false);
|
21
test/built-ins/WeakMap/prototype/delete/returns-false-when-delete-is-noop.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/delete/returns-false-when-delete-is-noop.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: >
|
||||
Return false if entry is not in the WeakMap.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
...
|
||||
7. Return false.
|
||||
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
var foo = {};
|
||||
var bar = {};
|
||||
|
||||
map.set(foo, 42);
|
||||
|
||||
assert.sameValue(map.delete(bar), false);
|
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-boolean.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-boolean.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(false, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(false, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-null.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-null.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(null, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(null, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-number.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-number.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(0, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(0, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-string.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-string.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call('', {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call('', {});
|
||||
});
|
21
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-symbol.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-symbol.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(Symbol(), {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(Symbol(), {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-undefined.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/delete/this-not-object-throw-undefined.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.2
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.delete ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.delete.call(undefined, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.delete.call(undefined, {});
|
||||
});
|
24
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Throws a TypeError if `this` is a Map object.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Map]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(new Map(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.get.call(new Map(), 1);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Throws a TypeError if `this` is a Set object.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Set]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(new Set(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.get.call(new Set(), 1);
|
||||
});
|
31
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot.js
vendored
Normal file
31
test/built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Throws a TypeError if `this` does not have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call([], 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
map.get.call([], 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call({}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
map.get.call({}, 1);
|
||||
});
|
22
test/built-ins/WeakMap/prototype/get/get.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/get/get.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Property type and descriptor.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof WeakMap.prototype.get,
|
||||
'function',
|
||||
'`typeof WeakMap.prototype.get` is `function`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype, 'get');
|
||||
verifyWritable(WeakMap.prototype, 'get');
|
||||
verifyConfigurable(WeakMap.prototype, 'get');
|
22
test/built-ins/WeakMap/prototype/get/length.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/get/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
WeakMap.prototype.get.length value and descriptor.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.get.length, 1,
|
||||
'The value of `WeakMap.prototype.get.length` is `1`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.get, 'length');
|
||||
verifyNotWritable(WeakMap.prototype.get, 'length');
|
||||
verifyConfigurable(WeakMap.prototype.get, 'length');
|
22
test/built-ins/WeakMap/prototype/get/name.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/get/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
WeakMap.prototype.get.name value and descriptor.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.get.name, 'get',
|
||||
'The value of `WeakMap.prototype.get.name` is `"get"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.get, 'name');
|
||||
verifyNotWritable(WeakMap.prototype.get, 'name');
|
||||
verifyConfigurable(WeakMap.prototype.get, 'name');
|
41
test/built-ins/WeakMap/prototype/get/returns-undefined-key-is-not-object.js
vendored
Normal file
41
test/built-ins/WeakMap/prototype/get/returns-undefined-key-is-not-object.js
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Returns undefined when key is not an Object.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of M’s [[WeakMapData]] internal
|
||||
slot.
|
||||
5. If Type(key) is not Object, return undefined.
|
||||
...
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.sameValue(map.get(null), undefined, 'Returns undefined if key is null');
|
||||
|
||||
assert.sameValue(map.get(NaN), undefined, 'Returns undefined if key is NaN');
|
||||
|
||||
assert.sameValue(
|
||||
map.get('foo'), undefined,
|
||||
'Returns undefined if key is a String'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
map.get(1), undefined,
|
||||
'Returns undefined if key is a Number'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
map.get(undefined), undefined,
|
||||
'Returns undefined if key is undefined'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
map.get(Symbol()), undefined,
|
||||
'Returns undefined if key is a Symbol'
|
||||
);
|
37
test/built-ins/WeakMap/prototype/get/returns-undefined.js
vendored
Normal file
37
test/built-ins/WeakMap/prototype/get/returns-undefined.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Returns undefined when key is not on the WeakMap object.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
4. Let entries be the List that is the value of M’s [[WeakMapData]] internal
|
||||
slot.
|
||||
5. If Type(key) is not Object, return undefined.
|
||||
6. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, return
|
||||
p.[[value]].
|
||||
7. Return undefined.
|
||||
...
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
var key = {};
|
||||
|
||||
assert.sameValue(
|
||||
map.get(key), undefined,
|
||||
'returns undefined if key is not on the weakmap'
|
||||
);
|
||||
|
||||
map.set(key, 1);
|
||||
map.set({}, 2);
|
||||
map.delete(key);
|
||||
map.set({}, 3);
|
||||
|
||||
assert.sameValue(
|
||||
map.get(key), undefined,
|
||||
'returns undefined if key was deleted'
|
||||
);
|
31
test/built-ins/WeakMap/prototype/get/returns-value.js
vendored
Normal file
31
test/built-ins/WeakMap/prototype/get/returns-value.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Returns the value from the specified key
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
4. Let entries be the List that is the value of M’s [[WeakMapData]] internal
|
||||
slot.
|
||||
5. If Type(key) is not Object, return undefined.
|
||||
6. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, return
|
||||
p.[[value]].
|
||||
...
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var bar = {};
|
||||
var baz = [];
|
||||
var map = new WeakMap([[foo,0]]);
|
||||
|
||||
assert.sameValue(map.get(foo), 0);
|
||||
|
||||
map.set(bar, 1);
|
||||
assert.sameValue(map.get(bar), 1);
|
||||
|
||||
map.set(baz, 2);
|
||||
assert.sameValue(map.get(baz), 2);
|
43
test/built-ins/WeakMap/prototype/get/this-not-object-throw.js
vendored
Normal file
43
test/built-ins/WeakMap/prototype/get/this-not-object-throw.js
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.3
|
||||
description: >
|
||||
Throws a TypeError if `this` value is not an Object.
|
||||
info: >
|
||||
WeakMap.prototype.get ( key )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(false, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(1, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call('', {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(undefined, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(null, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.get.call(Symbol(), {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.get.call(false, {});
|
||||
});
|
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call([], {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call([], {}, 1);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Map]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(new Map(), {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(new Map(), {}, 1);
|
||||
});
|
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call({}, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call({}, {}, 1);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Set]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(new Set(), {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(new Set(), {}, 1);
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(WeakMap.prototype, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(WeakMap.prototype, {}, 1);
|
||||
});
|
23
test/built-ins/WeakMap/prototype/has/has.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/has.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
WeakMap.prototype.has property descriptor
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof WeakMap.prototype.has,
|
||||
'function',
|
||||
'typeof WeakMap.prototype.has is "function"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype, 'has');
|
||||
verifyWritable(WeakMap.prototype, 'has');
|
||||
verifyConfigurable(WeakMap.prototype, 'has');
|
22
test/built-ins/WeakMap/prototype/has/length.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
WeakMap.prototype.has.length value and writability.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.has.length, 1,
|
||||
'The value of WeakMap.prototype.has.length is 1'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.has, 'length');
|
||||
verifyNotWritable(WeakMap.prototype.has, 'length');
|
||||
verifyConfigurable(WeakMap.prototype.has, 'length');
|
22
test/built-ins/WeakMap/prototype/has/name.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
WeakMap.prototype.has.name value and writability.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.has.name, 'has',
|
||||
'The value of WeakMap.prototype.has.name is "has"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.has, 'name');
|
||||
verifyNotWritable(WeakMap.prototype.has, 'name');
|
||||
verifyConfigurable(WeakMap.prototype.has, 'name');
|
21
test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Returns false if value is not an Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
5. If Type(key) is not Object, return false.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.sameValue(map.has(1), false);
|
||||
assert.sameValue(map.has(''), false);
|
||||
assert.sameValue(map.has(null), false);
|
||||
assert.sameValue(map.has(undefined), false);
|
||||
assert.sameValue(map.has(true), false);
|
||||
assert.sameValue(map.has(Symbol()), false);
|
25
test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
vendored
Normal file
25
test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Return false when value is not present in the WeakMap entries.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
7. Return false.
|
||||
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var bar = {};
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.sameValue(map.has(foo), false);
|
||||
|
||||
map.set(foo, 1);
|
||||
assert.sameValue(map.has(bar), false);
|
||||
|
||||
map.delete(foo);
|
||||
assert.sameValue(map.has(foo), false);
|
22
test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: >
|
||||
Returns true when value is present in the WeakMap entries list.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
...
|
||||
6. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, return
|
||||
true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var map = new WeakMap();
|
||||
|
||||
map.set(foo, 1);
|
||||
assert.sameValue(map.has(foo), true);
|
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(false, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(false, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(null, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(null, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(0, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(0, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call('', {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call('', {});
|
||||
});
|
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(Symbol(), {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(Symbol(), {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.4
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.has ( value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.has.call(undefined, {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.has.call(undefined, {});
|
||||
});
|
12
test/built-ins/WeakMap/prototype/prototype-attributes.js
vendored
Normal file
12
test/built-ins/WeakMap/prototype/prototype-attributes.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.2.1
|
||||
description: >
|
||||
WeakMap.prototype is not writable, not enumerable and not configurable.
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(WeakMap, 'prototype');
|
||||
verifyNotWritable(WeakMap, 'prototype');
|
||||
verifyNotConfigurable(WeakMap, 'prototype');
|
27
test/built-ins/WeakMap/prototype/set/adds-element.js
vendored
Normal file
27
test/built-ins/WeakMap/prototype/set/adds-element.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Appends value as the last element of entries.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
7. Let p be the Record {[[key]]: key, [[value]]: value}.
|
||||
8. Append p as the last element of entries.
|
||||
...
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
var foo = {};
|
||||
var bar = {};
|
||||
var baz = {};
|
||||
|
||||
map.set(foo, 1);
|
||||
map.set(bar, 2);
|
||||
map.set(baz, 3);
|
||||
|
||||
assert(map.has(foo));
|
||||
assert(map.has(bar));
|
||||
assert(map.has(baz));
|
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call([], {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call([], {}, 1);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Map]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(new Map(), {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(new Map(), {}, 1);
|
||||
});
|
23
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call({}, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call({}, {}, 1);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
features: [Set]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(new Set(), {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(new Set(), {}, 1);
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: >
|
||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
...
|
||||
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
|
||||
exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(WeakMap.prototype, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(WeakMap.prototype, {}, 1);
|
||||
});
|
37
test/built-ins/WeakMap/prototype/set/key-not-object-throw.js
vendored
Normal file
37
test/built-ins/WeakMap/prototype/set/key-not-object-throw.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `key` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
5. If Type(key) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var s = new WeakMap();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set(1, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set(false, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set(undefined, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set('string', 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set(null, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.set(Symbol(), 1);
|
||||
});
|
21
test/built-ins/WeakMap/prototype/set/length.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/set/length.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: WeakMap.prototype.set.length descriptor
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.set.length, 2,
|
||||
'The value of `WeakMap.prototype.set.length` is `2`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.set, 'length');
|
||||
verifyNotWritable(WeakMap.prototype.set, 'length');
|
||||
verifyConfigurable(WeakMap.prototype.set, 'length');
|
21
test/built-ins/WeakMap/prototype/set/name.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/set/name.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: WeakMap.prototype.set.name descriptor
|
||||
info: >
|
||||
WeakMap.prototype.set ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
WeakMap.prototype.set.name, 'set',
|
||||
'The value of WeakMap.prototype.set.name is "set"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype.set, 'name');
|
||||
verifyNotWritable(WeakMap.prototype.set, 'name');
|
||||
verifyConfigurable(WeakMap.prototype.set, 'name');
|
22
test/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Returns `this` when new value is duplicate.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
...
|
||||
6. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||
entries,
|
||||
a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, then
|
||||
i. Set p.[[value]] to value.
|
||||
ii. Return M.
|
||||
...
|
||||
---*/
|
||||
|
||||
var foo = {};
|
||||
var map = new WeakMap([[foo, 1]]);
|
||||
|
||||
assert.sameValue(map.set(foo, 1), map, '`map.set(foo, 1)` returns `map`');
|
17
test/built-ins/WeakMap/prototype/set/returns-this.js
vendored
Normal file
17
test/built-ins/WeakMap/prototype/set/returns-this.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Returns `this` after setting a new value.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be this value.
|
||||
...
|
||||
9. Return M.
|
||||
|
||||
---*/
|
||||
|
||||
var map = new WeakMap();
|
||||
|
||||
assert.sameValue(map.set({}, 1), map, '`map.set({}, 1)` returns `map`');
|
22
test/built-ins/WeakMap/prototype/set/set.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/set/set.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: WeakMap.prototype.set property descriptor
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof WeakMap.prototype.set,
|
||||
'function',
|
||||
'typeof WeakMap.prototype.set is "function"'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(WeakMap.prototype, 'set');
|
||||
verifyWritable(WeakMap.prototype, 'set');
|
||||
verifyConfigurable(WeakMap.prototype, 'set');
|
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(false, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(false, {}, 1);
|
||||
});
|
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(null, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(null, {}, 1);
|
||||
});
|
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(0, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(0, {}, 1);
|
||||
});
|
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call('', {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call('', {}, 1);
|
||||
});
|
21
test/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(Symbol(), {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(Symbol(), {}, 1);
|
||||
});
|
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5
|
||||
description: Throws TypeError if `this` is not Object.
|
||||
info: >
|
||||
WeakMap.prototype.set ( key, value )
|
||||
|
||||
1. Let M be the this value.
|
||||
2. If Type(M) is not Object, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap.prototype.set.call(undefined, {}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var map = new WeakMap();
|
||||
map.set.call(undefined, {}, 1);
|
||||
});
|
25
test/built-ins/WeakMap/set-not-callable-throws.js
Normal file
25
test/built-ins/WeakMap/set-not-callable-throws.js
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Throws TypeError if add is not callable on constructor call.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
...
|
||||
5. If iterable is not present, let iterable be undefined.
|
||||
6. If iterable is either undefined or null, let iter be undefined.
|
||||
7. Else,
|
||||
a. Let adder be Get(map, "set").
|
||||
b. ReturnIfAbrupt(adder).
|
||||
c. If IsCallable(adder) is false, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
WeakMap.prototype.set = null;
|
||||
new WeakMap();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new WeakMap([]);
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5_S2
|
||||
description: >
|
||||
Symbol may not be used as a WeakMap key
|
||||
features: [WeakMap]
|
||||
---*/
|
||||
var weakmap = new WeakMap();
|
||||
var sym = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
weakmap.set(sym, 1);
|
||||
});
|
19
test/built-ins/WeakMap/undefined-newtarget.js
Normal file
19
test/built-ins/WeakMap/undefined-newtarget.js
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
Throws a TypeError if NewTarget is undefined.
|
||||
info: >
|
||||
23.3.1.1 WeakMap ( [ iterable ] )
|
||||
|
||||
1. If NewTarget is undefined, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap();
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
WeakMap([]);
|
||||
});
|
14
test/built-ins/WeakMap/weakmap.js
Normal file
14
test/built-ins/WeakMap/weakmap.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.1.1
|
||||
description: >
|
||||
WeakMap ( [ iterable ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(this, 'WeakMap');
|
||||
verifyWritable(this, 'WeakMap');
|
||||
verifyConfigurable(this, 'WeakMap');
|
Loading…
x
Reference in New Issue
Block a user