Test primitive retval of Iterator and AsyncIterator getters

The existing test passed an object for a `this` value. This commit checks that
primitive values are returned verbatim, without any conversion.

Resolve #3489.
This commit is contained in:
Zirak 2022-07-23 12:14:26 +00:00 committed by Philip Chimento
parent dadf18f416
commit c665ccea28
2 changed files with 38 additions and 14 deletions

View File

@ -10,11 +10,22 @@ features: [Symbol.asyncIterator, async-iteration]
---*/ ---*/
async function* generator() {} async function* generator() {}
var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype))
const getAsyncIterator = AsyncIteratorPrototype[Symbol.asyncIterator];
var thisValue = {}; const thisValues = [
{},
Symbol(),
4,
4n,
true,
undefined,
null,
];
assert.sameValue( for (const thisValue of thisValues) {
AsyncIteratorPrototype[Symbol.asyncIterator].call(thisValue), assert.sameValue(
getAsyncIterator.call(thisValue),
thisValue thisValue
); );
}

View File

@ -1,19 +1,32 @@
// Copyright (C) 2015 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. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 25.1.2.1 esid: sec-%iteratorprototype%-@@iterator
description: Descriptor for `name` property description: Return value of @@iterator on IteratorPrototype
info: | info: |
%IteratorPrototype% [ @@iterator ] ( )
1. Return the this value. 1. Return the this value.
features: [Symbol.iterator] features: [Symbol.iterator]
---*/ ---*/
var IteratorPrototype = Object.getPrototypeOf( const IteratorPrototype = Object.getPrototypeOf(
Object.getPrototypeOf([][Symbol.iterator]()) Object.getPrototypeOf([][Symbol.iterator]())
); );
var thisValue = {}; const getIterator = IteratorPrototype[Symbol.iterator];
assert.sameValue( const thisValues = [
IteratorPrototype[Symbol.iterator].call(thisValue), {},
Symbol(),
4,
4n,
true,
undefined,
null,
];
for (const thisValue of thisValues) {
assert.sameValue(
getIterator.call(thisValue),
thisValue thisValue
); );
}