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/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js')
-rw-r--r-- | js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..c4697dc91e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,107 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); |