diff --git a/test/built-ins/MapIteratorPrototype/Symbol.toStringTag.js b/test/built-ins/MapIteratorPrototype/Symbol.toStringTag.js index 6eadb5ac5b0fa26d4641e5c528ab05065a45f6aa..d69331c9cc4f11139b1a609e95bb4ed917081bb9 100644 --- a/test/built-ins/MapIteratorPrototype/Symbol.toStringTag.js +++ b/test/built-ins/MapIteratorPrototype/Symbol.toStringTag.js @@ -1,12 +1,11 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- - description: > - `Object.prototype.getOwnPropertyDescriptor` should reflect the value and - writability of the @@toStringTag attribute. - includes: [propertyHelper.js] - es6id: 23.1.3.13 +es6id: 23.1.5.2.2 +description: > + `Object.prototype.getOwnPropertyDescriptor` should reflect the value and + writability of the @@toStringTag attribute. +includes: [propertyHelper.js] ---*/ var MapIteratorProto = Object.getPrototypeOf(new Map()[Symbol.iterator]()); diff --git a/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js b/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js new file mode 100644 index 0000000000000000000000000000000000000000..3adbd2d36ab3613dc90478887e71985a048a77d4 --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js @@ -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); +}); diff --git a/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js b/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js new file mode 100644 index 0000000000000000000000000000000000000000..cc91197a883757f2d547696fccce5f1162259cb0 --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js @@ -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]()); diff --git a/test/built-ins/MapIteratorPrototype/next/iteration-mutable.js b/test/built-ins/MapIteratorPrototype/next/iteration-mutable.js index 160dfd2fd2ac52010d9e93704ba001b15b972cd7..0dfee3241c3856bde16a0ff29996278f8c3153da 100644 --- a/test/built-ins/MapIteratorPrototype/next/iteration-mutable.js +++ b/test/built-ins/MapIteratorPrototype/next/iteration-mutable.js @@ -1,14 +1,14 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- - description: > - When an item is added to the map after the iterator is created but before - the iterator is "done" (as defined by 23.1.5.2.1), the new item should be - accessible via iteration. When an item is added to the map after the - iterator is "done", the new item should not be accessible via iteration. - es6id: 23.1.3.12 - ---*/ +es6id: 23.1.3.12 +description: > + When an item is added to the map after the iterator is created but before + the iterator is "done" (as defined by 23.1.5.2.1), the new item should be + accessible via iteration. When an item is added to the map after the + iterator is "done", the new item should not be accessible via iteration. +features: [Symbol.iterator] +---*/ var map = new Map(); map.set(1, 11); diff --git a/test/built-ins/MapIteratorPrototype/next/iteration.js b/test/built-ins/MapIteratorPrototype/next/iteration.js index 1532f27eeacffbf27762a0523aa6f52d9ccf58e0..178b0444317306195a1e2edb01ae20c66e2cae13 100644 --- a/test/built-ins/MapIteratorPrototype/next/iteration.js +++ b/test/built-ins/MapIteratorPrototype/next/iteration.js @@ -1,11 +1,11 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- - description: > - The method should return a valid iterator with the context as the - IteratedObject. - es6id: 23.2.3.11 +es6id: 23.1.3.12 +description: > + The method should return a valid iterator with the context as the + IteratedObject. +features: [Symbol.iterator] ---*/ var map = new Map(); diff --git a/test/built-ins/MapIteratorPrototype/next/no-map-data.js b/test/built-ins/MapIteratorPrototype/next/no-map-data.js deleted file mode 100644 index a6ea3f6eb91d622622cb4a19a7e0bed1103da4a2..0000000000000000000000000000000000000000 --- a/test/built-ins/MapIteratorPrototype/next/no-map-data.js +++ /dev/null @@ -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({}); -}); diff --git a/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js new file mode 100644 index 0000000000000000000000000000000000000000..6f2680785cdd797ad02bb31eee336a2c4932bbf8 --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js @@ -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]()); diff --git a/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js new file mode 100644 index 0000000000000000000000000000000000000000..9dfdce8495236b3b24056f75a457b5697a9bdb3e --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js @@ -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]()); diff --git a/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..c276879d9e2a2b5d3d1cc3e1993d5959c134bc57 --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js @@ -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]()); diff --git a/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js new file mode 100644 index 0000000000000000000000000000000000000000..99511565fecab663913c86c457cff22d378cbf5b --- /dev/null +++ b/test/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js @@ -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]());