diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js')
-rw-r--r-- | js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js b/js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js new file mode 100644 index 0000000000..f962045044 --- /dev/null +++ b/js/src/tests/test262/language/statements/async-generator/yield-star-async-from-sync-iterator-inaccessible.js @@ -0,0 +1,56 @@ +// |reftest| async +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createasyncfromsynciterator +description: > + Async-from-Sync Iterator instances are not accessible from user code. +info: | + 25.1.4.1 CreateAsyncFromSyncIterator ( syncIteratorRecord ) + 1. Let asyncIterator be ! ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). + 2. Set asyncIterator.[[SyncIteratorRecord]] to syncIteratorRecord. + 3. Let nextMethod be ! Get(asyncIterator, "next"). + 4. Let iteratorRecord be Record { [[Iterator]]: asyncIterator, [[NextMethod]]: nextMethod, [[Done]]: false }. + 5. Return iteratorRecord. + + 14.4.14 Runtime Semantics: Evaluation + YieldExpression : yield * AssignmentExpression + 1. Let generatorKind be ! GetGeneratorKind(). + ... + 4. Let iteratorRecord be ? GetIterator(value, generatorKind). + ... + + 7.4.1 GetIterator ( obj [ , hint [ , method ] ] ) + ... + 3. If method is not present, then + a. If hint is async, then + i. Set method to ? GetMethod(obj, @@asyncIterator). + ii. If method is undefined, then + 1. Let syncMethod be ? GetMethod(obj, @@iterator). + 2. Let syncIteratorRecord be ? GetIterator(obj, sync, syncMethod). + 3. Return ? CreateAsyncFromSyncIterator(syncIteratorRecord). + ... + +flags: [async] +features: [async-iteration] +---*/ + +var AsyncIteratorPrototype = Object.getPrototypeOf(async function*(){}.constructor.prototype.prototype); + +Object.defineProperty(AsyncIteratorPrototype, Symbol.iterator, { + get() { + throw new Error("@@iterator accessed"); + } +}); + +Object.defineProperty(AsyncIteratorPrototype, Symbol.asyncIterator, { + get() { + throw new Error("@@asyncIterator accessed"); + } +}); + +async function* g() { + yield* []; +} +g().next().then(() => $DONE(), $DONE); |