summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js
parentInitial commit. (diff)
downloadfirefox-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/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js')
-rw-r--r--js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js b/js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js
new file mode 100644
index 0000000000..8f6062bd4d
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js
@@ -0,0 +1,73 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-generator-function-definitions-runtime-semantics-evaluation
+es6id: 14.4.14
+description: >
+ Abrupt completion returned when invoking iterator `return` method following
+ protocol violation
+info: |
+ YieldExpression : yield * AssignmentExpression
+
+ 1. Let exprRef be the result of evaluating AssignmentExpression.
+ 2. Let value be ? GetValue(exprRef).
+ 3. Let iterator be ? GetIterator(value).
+ 4. Let received be NormalCompletion(undefined).
+ 5. Repeat
+ a. If received.[[Type]] is normal, then
+ [...]
+ b. Else if received.[[Type]] is throw, then
+ i. Let throw be ? GetMethod(iterator, "throw").
+ ii. If throw is not undefined, then
+ [...]
+ iii. Else,
+ 1. NOTE: If iterator does not have a throw method, this throw is
+ going to terminate the yield* loop. But first we need to give
+ iterator a chance to clean up.
+ 2. Perform ? IteratorClose(iterator, Completion{[[Type]]: normal,
+ [[Value]]: empty, [[Target]]: empty}).
+
+ 7.4.6 IteratorClose
+
+ 1. Assert: Type(iterator) is Object.
+ 2. Assert: completion is a Completion Record.
+ 3. Let return be ? GetMethod(iterator, "return").
+ 4. If return is undefined, return Completion(completion).
+ 5. Let innerResult be Call(return, iterator, « »).
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+ 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
+features: [generators, Symbol.iterator]
+---*/
+
+var badIter = {};
+badIter[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ return { done: false };
+ },
+ return: function() {
+ // Using a primitive completion value ensures that the check for the type
+ // of the completion value (and resulting TypeError) occurs *after* the
+ // check for the type of the completion itself (which is the behavior
+ // under test).
+ throw 87;
+ }
+ };
+};
+function* g() {
+ try {
+ yield * badIter;
+ } catch (err) {
+ caught = err;
+ }
+}
+var iter = g();
+var caught;
+
+iter.next();
+iter.throw();
+
+assert.sameValue(caught, 87);
+
+reportCompare(0, 0);