mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Merge pull request #343 from bocoup/MapIteratorPrototype
Fix, update and improve coverage of MapIteratorPrototype
This commit is contained in:
commit
f4e17963f8
@ -1,12 +1,11 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
es6id: 23.1.5.2.2
|
||||||
`Object.prototype.getOwnPropertyDescriptor` should reflect the value and
|
description: >
|
||||||
writability of the @@toStringTag attribute.
|
`Object.prototype.getOwnPropertyDescriptor` should reflect the value and
|
||||||
includes: [propertyHelper.js]
|
writability of the @@toStringTag attribute.
|
||||||
es6id: 23.1.3.13
|
includes: [propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var MapIteratorProto = Object.getPrototypeOf(new Map()[Symbol.iterator]());
|
var MapIteratorProto = Object.getPrototypeOf(new Map()[Symbol.iterator]());
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
// 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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` does not have all of the internal slots of a Map
|
||||||
|
Iterator Instance.
|
||||||
|
info: >
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
3. If O does not have all of the internal slots of a Map Iterator Instance
|
||||||
|
(23.1.5.3), throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
|
||||||
|
var iterator = map[Symbol.iterator]();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(map);
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.entries();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(map);
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.keys();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(map);
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.values();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(map);
|
||||||
|
});
|
@ -0,0 +1,42 @@
|
|||||||
|
// 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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` does not have all of the internal slots of a Map
|
||||||
|
Iterator Instance.
|
||||||
|
info: >
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
3. If O does not have all of the internal slots of a Map Iterator Instance
|
||||||
|
(23.1.5.3), throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
|
||||||
|
var iterator = map[Symbol.iterator]();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.entries();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.keys();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
iterator = map.values();
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
// does not throw an Error
|
||||||
|
iterator.next.call(map[Symbol.iterator]());
|
@ -1,14 +1,14 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
es6id: 23.1.3.12
|
||||||
When an item is added to the map after the iterator is created but before
|
description: >
|
||||||
the iterator is "done" (as defined by 23.1.5.2.1), the new item should be
|
When an item is added to the map after the iterator is created but before
|
||||||
accessible via iteration. When an item is added to the map after the
|
the iterator is "done" (as defined by 23.1.5.2.1), the new item should be
|
||||||
iterator is "done", the new item should not be accessible via iteration.
|
accessible via iteration. When an item is added to the map after the
|
||||||
es6id: 23.1.3.12
|
iterator is "done", the new item should not be accessible via iteration.
|
||||||
---*/
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
var map = new Map();
|
var map = new Map();
|
||||||
map.set(1, 11);
|
map.set(1, 11);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
es6id: 23.1.3.12
|
||||||
The method should return a valid iterator with the context as the
|
description: >
|
||||||
IteratedObject.
|
The method should return a valid iterator with the context as the
|
||||||
es6id: 23.2.3.11
|
IteratedObject.
|
||||||
|
features: [Symbol.iterator]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var map = new Map();
|
var map = new Map();
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
If the context does not have a [[MapData]] internal slot, throw a
|
|
||||||
TypeError exception as per 23.1.5.1.
|
|
||||||
es6id: 23.1.3.12
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var iterator = new Map()[Symbol.iterator]();
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
iterator.next.call({});
|
|
||||||
});
|
|
@ -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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` value is not an Object.
|
||||||
|
info: >
|
||||||
|
From Map.prototype.entries()
|
||||||
|
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features:
|
||||||
|
- Symbol
|
||||||
|
- Symbol.iterator
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
var iterator = map.entries();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(Symbol());
|
||||||
|
});
|
||||||
|
|
||||||
|
// does not throw an Error
|
||||||
|
iterator.next.call(map[Symbol.iterator]());
|
@ -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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` value is not an Object.
|
||||||
|
info: >
|
||||||
|
From Map.prototype.keys()
|
||||||
|
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features:
|
||||||
|
- Symbol
|
||||||
|
- Symbol.iterator
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
var iterator = map.keys();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(Symbol());
|
||||||
|
});
|
||||||
|
|
||||||
|
// does not throw an Error
|
||||||
|
iterator.next.call(map[Symbol.iterator]());
|
@ -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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` value is not an Object.
|
||||||
|
info: >
|
||||||
|
Using Map.prototype[Symbol.iterator]()
|
||||||
|
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features:
|
||||||
|
- Symbol
|
||||||
|
- Symbol.iterator
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
var iterator = map[Symbol.iterator]();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(Symbol());
|
||||||
|
});
|
||||||
|
|
||||||
|
// does not throw an Error
|
||||||
|
iterator.next.call(map[Symbol.iterator]());
|
@ -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.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` value is not an Object.
|
||||||
|
info: >
|
||||||
|
From Map.prototype.values()
|
||||||
|
|
||||||
|
%MapIteratorPrototype%.next ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features:
|
||||||
|
- Symbol
|
||||||
|
- Symbol.iterator
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[1, 11], [2, 22]]);
|
||||||
|
var iterator = map.values();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call(Symbol());
|
||||||
|
});
|
||||||
|
|
||||||
|
// does not throw an Error
|
||||||
|
iterator.next.call(map[Symbol.iterator]());
|
Loading…
x
Reference in New Issue
Block a user