diff --git a/test/built-ins/AsyncFromSyncIteratorPrototype/throw/absent-value-not-passed.js b/test/built-ins/AsyncFromSyncIteratorPrototype/throw/absent-value-not-passed.js new file mode 100644 index 0000000000..b713c4d3fa --- /dev/null +++ b/test/built-ins/AsyncFromSyncIteratorPrototype/throw/absent-value-not-passed.js @@ -0,0 +1,45 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%asyncfromsynciteratorprototype%.throw +description: > + `throw` method does not pass absent `value`. +info: | + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + [...] + 8. If value is present, then + [...] + 9. Else, + a. Let result be Call(throw, syncIterator). + [...] +flags: [async] +features: [async-iteration] +---*/ + +var throwArgumentsLength; +var syncIterator = { + [Symbol.iterator]() { + return this; + }, + next() { + return {done: false}; + }, + throw() { + throwArgumentsLength = arguments.length; + return {done: true}; + }, +}; + +var asyncIterator = (async function* () { + yield* syncIterator; +})(); + +asyncIterator.next().then(function() { + return asyncIterator.throw(); +}).then(function(result) { + throw new Test262Error("Promise should be rejected, got: " + result.value); +}, function() { + assert.sameValue(throwArgumentsLength, 0); +}).then($DONE, $DONE);