| 1 |
// |reftest| async |
| 2 |
// Copyright (C) 2019 André Bargull. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-createasyncfromsynciterator |
| 7 |
description: > |
| 8 |
Async-from-Sync Iterator instances are not accessible from user code. |
| 9 |
info: | |
| 10 |
25.1.4.1 CreateAsyncFromSyncIterator ( syncIteratorRecord ) |
| 11 |
1. Let asyncIterator be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). |
| 12 |
2. Set asyncIterator.[[SyncIteratorRecord]] to syncIteratorRecord. |
| 13 |
3. Let nextMethod be ! Get(asyncIterator, "next"). |
| 14 |
4. Let iteratorRecord be Record { [[Iterator]]: asyncIterator, [[NextMethod]]: nextMethod, [[Done]]: false }. |
| 15 |
5. Return iteratorRecord. |
| 16 |
|
| 17 |
14.4.14 Runtime Semantics: Evaluation |
| 18 |
YieldExpression : yield * AssignmentExpression |
| 19 |
1. Let generatorKind be ! GetGeneratorKind(). |
| 20 |
... |
| 21 |
4. Let iteratorRecord be ? GetIterator(value, generatorKind). |
| 22 |
... |
| 23 |
|
| 24 |
7.4.1 GetIterator ( obj [ , hint [ , method ] ] ) |
| 25 |
... |
| 26 |
3. If method is not present, then |
| 27 |
a. If hint is async, then |
| 28 |
i. Set method to ? GetMethod(obj, @@asyncIterator). |
| 29 |
ii. If method is undefined, then |
| 30 |
1. Let syncMethod be ? GetMethod(obj, @@iterator). |
| 31 |
2. Let syncIteratorRecord be ? GetIterator(obj, sync, syncMethod). |
| 32 |
3. Return ? CreateAsyncFromSyncIterator(syncIteratorRecord). |
| 33 |
... |
| 34 |
|
| 35 |
flags: [async] |
| 36 |
features: [async-iteration] |
| 37 |
---*/ |
| 38 |
|
| 39 |
var AsyncIteratorPrototype = Object.getPrototypeOf(async function*(){}.constructor.prototype.prototype); |
| 40 |
|
| 41 |
Object.defineProperty(AsyncIteratorPrototype, Symbol.iterator, { |
| 42 |
get() { |
| 43 |
throw new Error("@@iterator accessed"); |
| 44 |
} |
| 45 |
}); |
| 46 |
|
| 47 |
Object.defineProperty(AsyncIteratorPrototype, Symbol.asyncIterator, { |
| 48 |
get() { |
| 49 |
throw new Error("@@asyncIterator accessed"); |
| 50 |
} |
| 51 |
}); |
| 52 |
|
| 53 |
async function* g() { |
| 54 |
yield* []; |
| 55 |
} |
| 56 |
g().next().then(() => $DONE(), $DONE); |