mirror of https://github.com/tc39/test262.git
WeakMap - core tests
This commit is contained in:
parent
0027a6b6bf
commit
f0ec4e6de1
|
@ -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"'
|
||||||
|
);
|
|
@ -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'
|
||||||
|
);
|
|
@ -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([]);
|
||||||
|
});
|
|
@ -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({});
|
||||||
|
});
|
|
@ -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');
|
|
@ -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);
|
|
@ -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]);
|
||||||
|
});
|
|
@ -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);
|
||||||
|
});
|
|
@ -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);
|
||||||
|
});
|
|
@ -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');
|
|
@ -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');
|
|
@ -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);
|
|
@ -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`'
|
||||||
|
);
|
|
@ -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`'
|
||||||
|
);
|
|
@ -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);
|
|
||||||
});
|
|
|
@ -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([]);
|
||||||
|
});
|
|
@ -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…
Reference in New Issue