diff --git a/test/built-ins/Array/prototype/entries/entries.js b/test/built-ins/Array/prototype/entries/entries.js new file mode 100644 index 0000000000000000000000000000000000000000..9d51a3e86e75fe49c4a00168686337d9c33748b4 --- /dev/null +++ b/test/built-ins/Array/prototype/entries/entries.js @@ -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: 22.1.3.4 +description: > + Property type and descriptor. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.entries, + 'function', + '`typeof Array.prototype.entries` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'entries'); +verifyWritable(Array.prototype, 'entries'); +verifyConfigurable(Array.prototype, 'entries'); diff --git a/test/built-ins/Array/prototype/entries/iteration-mutable.js b/test/built-ins/Array/prototype/entries/iteration-mutable.js index e5df017cf4f19a9bfc7bbe64c3b75f1692e3982a..5e83551d619f4dc5cfe4c3c404fb4b65906afbb4 100644 --- a/test/built-ins/Array/prototype/entries/iteration-mutable.js +++ b/test/built-ins/Array/prototype/entries/iteration-mutable.js @@ -1,14 +1,15 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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. When an item is added to the array after the iterator is - created but before the iterator is "done" (as defined by 22.1.5.2.1) the - new item should be accessible via iteration. - es6id: 22.1.3.4 - ---*/ +es6id: 22.1.3.4 +description: > + New items in the array are accessible via iteration until iterator is "done". +info: > + The method should return a valid iterator with the context as the + IteratedObject. When an item is added to the array after the iterator is + created but before the iterator is "done" (as defined by 22.1.5.2.1) the + new item should be accessible via iteration. +---*/ var array = []; var iterator = array.entries(); diff --git a/test/built-ins/Array/prototype/entries/iteration.js b/test/built-ins/Array/prototype/entries/iteration.js index f15a26e78b1aa1f09796a42038a88b7a9a56a22c..a3b43a9ff03fe56ecc0f4b5ba12bf685fd99bdd4 100644 --- a/test/built-ins/Array/prototype/entries/iteration.js +++ b/test/built-ins/Array/prototype/entries/iteration.js @@ -1,20 +1,21 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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: 22.1.3.4 - ---*/ +es6id: 22.1.3.4 +description: > + The return is a valid iterator with the array's numeric properties. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +---*/ -var ArrayIteratorPrototype = Object.getPrototypeOf(Array.prototype[Symbol.iterator]()); var array = ['a', 'b', 'c']; var iterator = array.entries(); var result; -assert.sameValue(ArrayIteratorPrototype, Object.getPrototypeOf(array.entries())); - result = iterator.next(); assert.sameValue(result.done, false, 'First result `done` flag'); assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); diff --git a/test/built-ins/Array/prototype/entries/length.js b/test/built-ins/Array/prototype/entries/length.js new file mode 100644 index 0000000000000000000000000000000000000000..bf2997f388d8d2477af73da83f4b62cffd3cbc4d --- /dev/null +++ b/test/built-ins/Array/prototype/entries/length.js @@ -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: 22.1.3.4 +description: > + Array.prototype.entries.length value and descriptor. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.length, 0, + 'The value of `Array.prototype.entries.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.entries, 'length'); +verifyNotWritable(Array.prototype.entries, 'length'); +verifyConfigurable(Array.prototype.entries, 'length'); diff --git a/test/built-ins/Array/prototype/entries/name.js b/test/built-ins/Array/prototype/entries/name.js new file mode 100644 index 0000000000000000000000000000000000000000..7c8b7d7248ad804e1e5fca8d463b9a735829d01d --- /dev/null +++ b/test/built-ins/Array/prototype/entries/name.js @@ -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: 22.1.3.4 +description: > + Array.prototype.entries.name value and descriptor. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.name, 'entries', + 'The value of `Array.prototype.entries.name` is `"entries"`' +); + +verifyNotEnumerable(Array.prototype.entries, 'name'); +verifyNotWritable(Array.prototype.entries, 'name'); +verifyConfigurable(Array.prototype.entries, 'name'); diff --git a/test/built-ins/Array/prototype/entries/property-descriptor.js b/test/built-ins/Array/prototype/entries/property-descriptor.js deleted file mode 100644 index 888ab3173e8fdd62ac2b9393041451bac4be5af6..0000000000000000000000000000000000000000 --- a/test/built-ins/Array/prototype/entries/property-descriptor.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- - description: > - The method should exist on the Array prototype, and it should be writable - and configurable, but not enumerable. - includes: [propertyHelper.js] - es6id: 17 - ---*/ - -verifyNotEnumerable(Array.prototype, 'entries'); -verifyWritable(Array.prototype, 'entries'); -verifyConfigurable(Array.prototype, 'entries'); diff --git a/test/built-ins/Array/prototype/entries/return-abrupt-from-this.js b/test/built-ins/Array/prototype/entries/return-abrupt-from-this.js new file mode 100644 index 0000000000000000000000000000000000000000..762152421c01d4d43f56c6e68d4632450707c06e --- /dev/null +++ b/test/built-ins/Array/prototype/entries/return-abrupt-from-this.js @@ -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: 22.1.3.4 +description: > + Return abrupt from ToObject(this value). +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.entries.call(null); +}); diff --git a/test/built-ins/Array/prototype/entries/returns-iterator-from-object.js b/test/built-ins/Array/prototype/entries/returns-iterator-from-object.js new file mode 100644 index 0000000000000000000000000000000000000000..d937bd80900da4fe2306e92009f787fda04c09f7 --- /dev/null +++ b/test/built-ins/Array/prototype/entries/returns-iterator-from-object.js @@ -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: 22.1.3.4 +description: > + Creates an iterator from a custom object. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.entries.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); diff --git a/test/built-ins/Array/prototype/entries/returns-iterator.js b/test/built-ins/Array/prototype/entries/returns-iterator.js index 22b8aa9c53b0c6fcda52abf31989de5e3a6456f2..987e7f6358e602c5ad36aa9d2ae5adfdf0e045e1 100644 --- a/test/built-ins/Array/prototype/entries/returns-iterator.js +++ b/test/built-ins/Array/prototype/entries/returns-iterator.js @@ -1,13 +1,30 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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 an Iterator instance. - es6id: 22.1.3.4 - ---*/ +es6id: 22.1.3.4 +description: > + The method should return an Iterator instance. +info: > + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «â€[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); var iter = [].entries(); -assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); diff --git a/test/built-ins/Array/prototype/keys/iteration-mutable.js b/test/built-ins/Array/prototype/keys/iteration-mutable.js index 4f77993b6a5a82c9cf87ef6d40ddff331ffc0652..6b20255cb9cd3cae279b25e45fc8b6ec6a9f211d 100644 --- a/test/built-ins/Array/prototype/keys/iteration-mutable.js +++ b/test/built-ins/Array/prototype/keys/iteration-mutable.js @@ -1,15 +1,16 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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 array after the iterator is created but - before the iterator is "done" (as defined by 22.1.5.2.1), the new item's - key should be accessible via iteration. When an item is added to the - array after the iterator is "done", the new item's key should not be - accessible via iteration. - es6id: 22.1.3.13 - ---*/ +es6id: 22.1.3.13 +description: > + New items in the array are accessible via iteration until iterator is "done". +info: > + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + key should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item's key should not be + accessible via iteration. +---*/ var array = []; var iterator = array.keys(); @@ -28,5 +29,11 @@ assert.sameValue(result.value, undefined, 'Exhausted result `value`'); array.push('b'); result = iterator.next(); -assert.sameValue(result.done, true, 'Exhausted result `done` flag (after push)'); -assert.sameValue(result.value, undefined, 'Exhausted result `value` (after push)'); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); diff --git a/test/built-ins/Array/prototype/keys/iteration.js b/test/built-ins/Array/prototype/keys/iteration.js index 7e964bbe553e1b8ce4f25b632720f8d876d7a065..e9a71fb57a17b2b2f88ad4345ccb01c301aacc4e 100644 --- a/test/built-ins/Array/prototype/keys/iteration.js +++ b/test/built-ins/Array/prototype/keys/iteration.js @@ -1,12 +1,16 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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 array's numeric - properties as the IteratedObject. - es6id: 22.1.3.13 - ---*/ +es6id: 22.1.3.13 +description: > + The return is a valid iterator with the array's numeric properties. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +---*/ var array = ['a', 'b', 'c']; var iterator = array.keys(); diff --git a/test/built-ins/Array/prototype/keys/keys.js b/test/built-ins/Array/prototype/keys/keys.js new file mode 100644 index 0000000000000000000000000000000000000000..502e66f6362a67e8c6c5910fe74078aa19824b76 --- /dev/null +++ b/test/built-ins/Array/prototype/keys/keys.js @@ -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: 22.1.3.13 +description: > + Property type and descriptor. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.keys, + 'function', + '`typeof Array.prototype.keys` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'keys'); +verifyWritable(Array.prototype, 'keys'); +verifyConfigurable(Array.prototype, 'keys'); diff --git a/test/built-ins/Array/prototype/keys/length.js b/test/built-ins/Array/prototype/keys/length.js new file mode 100644 index 0000000000000000000000000000000000000000..0ebabd6fb9a8c7ed8500c6b3b7bd275d9c50b78c --- /dev/null +++ b/test/built-ins/Array/prototype/keys/length.js @@ -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: 22.1.3.13 +description: > + Array.prototype.keys.length value and descriptor. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.keys.length, 0, + 'The value of `Array.prototype.keys.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.keys, 'length'); +verifyNotWritable(Array.prototype.keys, 'length'); +verifyConfigurable(Array.prototype.keys, 'length'); diff --git a/test/built-ins/Array/prototype/keys/name.js b/test/built-ins/Array/prototype/keys/name.js new file mode 100644 index 0000000000000000000000000000000000000000..2d036f7f7a7c318fec77c150b127a8fb4f203e4b --- /dev/null +++ b/test/built-ins/Array/prototype/keys/name.js @@ -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: 22.1.3.13 +description: > + Array.prototype.keys.name value and descriptor. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.keys.name, 'keys', + 'The value of `Array.prototype.keys.name` is `"keys"`' +); + +verifyNotEnumerable(Array.prototype.keys, 'name'); +verifyNotWritable(Array.prototype.keys, 'name'); +verifyConfigurable(Array.prototype.keys, 'name'); diff --git a/test/built-ins/Array/prototype/keys/property-descriptor.js b/test/built-ins/Array/prototype/keys/property-descriptor.js deleted file mode 100644 index b9d5af2b8205400e6529350b2902700ebd9e1c77..0000000000000000000000000000000000000000 --- a/test/built-ins/Array/prototype/keys/property-descriptor.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- - description: > - The method should exist on the Array prototype, and it should be writable - and configurable, but not enumerable. - includes: [propertyHelper.js] - es6id: 22.1.3.13 - ---*/ - -verifyNotEnumerable(Array.prototype, 'keys'); -verifyWritable(Array.prototype, 'keys'); -verifyConfigurable(Array.prototype, 'keys'); diff --git a/test/built-ins/Array/prototype/keys/return-abrupt-from-this.js b/test/built-ins/Array/prototype/keys/return-abrupt-from-this.js new file mode 100644 index 0000000000000000000000000000000000000000..9905e8e4acce92ffe6f60ba14e2823fa228c1c96 --- /dev/null +++ b/test/built-ins/Array/prototype/keys/return-abrupt-from-this.js @@ -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: 22.1.3.13 +description: > + Return abrupt from ToObject(this value). +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.keys.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.keys.call(null); +}); diff --git a/test/built-ins/Array/prototype/keys/returns-iterator-from-object.js b/test/built-ins/Array/prototype/keys/returns-iterator-from-object.js new file mode 100644 index 0000000000000000000000000000000000000000..d28554bdf9732a36125f76e2df1a09899abf2fed --- /dev/null +++ b/test/built-ins/Array/prototype/keys/returns-iterator-from-object.js @@ -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: 22.1.3.13 +description: > + Creates an iterator from a custom object. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.keys.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); diff --git a/test/built-ins/Array/prototype/keys/returns-iterator.js b/test/built-ins/Array/prototype/keys/returns-iterator.js index b5a8adee780ee3d0dfd6a0f09e2211bc2b9c53d7..10ce2a580b84fb2f51dea1265eab05fc0171910d 100644 --- a/test/built-ins/Array/prototype/keys/returns-iterator.js +++ b/test/built-ins/Array/prototype/keys/returns-iterator.js @@ -1,13 +1,30 @@ -// Copyright (C) 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2015 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 an Iterator instance. - es6id: 22.1.3.13 - ---*/ +es6id: 22.1.3.13 +description: > + The method should return an Iterator instance. +info: > + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «â€[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); var iter = [].keys(); -assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); diff --git a/test/built-ins/Array/prototype/values/iteration-mutable.js b/test/built-ins/Array/prototype/values/iteration-mutable.js new file mode 100644 index 0000000000000000000000000000000000000000..ab69b540dba2ce7fee8479b1895ccd9478d90d63 --- /dev/null +++ b/test/built-ins/Array/prototype/values/iteration-mutable.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: 22.1.3.29 +description: > + New items in the array are accessible via iteration until iterator is "done". +info: > + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + value should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item should not be + accessible via iteration. +---*/ + +var array = []; +var iterator = array.values(); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false , 'First result `done` flag'); +assert.sameValue(result.value, 'a', 'First result `value`'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); diff --git a/test/built-ins/Array/prototype/values/iteration.js b/test/built-ins/Array/prototype/values/iteration.js new file mode 100644 index 0000000000000000000000000000000000000000..c67752ae077e22dfe134f4f92ef0aaac7def6e0e --- /dev/null +++ b/test/built-ins/Array/prototype/values/iteration.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.3.29 +description: > + The return is a valid iterator with the array's numeric properties. +info: > + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'a', 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'b', 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'c', 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); diff --git a/test/built-ins/Array/prototype/values/returns-iterator-from-object.js b/test/built-ins/Array/prototype/values/returns-iterator-from-object.js new file mode 100644 index 0000000000000000000000000000000000000000..1e1c813c49b0b7e25778015bf27bd6e6cdedb9d7 --- /dev/null +++ b/test/built-ins/Array/prototype/values/returns-iterator-from-object.js @@ -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: 22.1.3.29 +description: > + Creates an iterator from a custom object. +info: > + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.values.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +); diff --git a/test/built-ins/Array/prototype/values/returns-iterator.js b/test/built-ins/Array/prototype/values/returns-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..14cb8bf24063dbb88f66bf5df7974a3218aca2f0 --- /dev/null +++ b/test/built-ins/Array/prototype/values/returns-iterator.js @@ -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: 22.1.3.29 +description: > + The method should return an Iterator instance. +info: > + 22.1.3.29 Array.prototype.values ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «â€[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].values(); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +);