mirror of https://github.com/tc39/test262.git
Add `return` method test
This commit is contained in:
parent
1bf4e159dd
commit
543370c44d
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-%asyncfromsynciteratorprototype%.return
|
||||
description: >
|
||||
`return` method does not pass absent `value`.
|
||||
info: |
|
||||
%AsyncFromSyncIteratorPrototype%.return ( value )
|
||||
|
||||
[...]
|
||||
8. If value is present, then
|
||||
[...]
|
||||
9. Else,
|
||||
a. Let result be Call(return, syncIterator).
|
||||
[...]
|
||||
flags: [async]
|
||||
features: [async-iteration]
|
||||
---*/
|
||||
|
||||
var returnArgumentsLength;
|
||||
var syncIterator = {
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
},
|
||||
next() {
|
||||
return {done: false};
|
||||
},
|
||||
return() {
|
||||
returnArgumentsLength = arguments.length;
|
||||
return {done: true};
|
||||
},
|
||||
};
|
||||
|
||||
var asyncIterator = (async function* () {
|
||||
yield* syncIterator;
|
||||
})();
|
||||
|
||||
asyncIterator.next().then(function() {
|
||||
return asyncIterator.return();
|
||||
}).then(function() {
|
||||
assert.sameValue(returnArgumentsLength, 0);
|
||||
}).then($DONE, $DONE);
|
Loading…
Reference in New Issue