From 70870dc239a59c6f951a1c92f0d6c4dc64e6d78a Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Mon, 27 Mar 2017 21:44:04 -0400 Subject: [PATCH] Generate tests --- ...ed-yield-star-next-call-done-get-abrupt.js | 72 ++++++++++++++ ...med-yield-star-next-call-returns-abrupt.js | 64 +++++++++++++ ...d-yield-star-next-call-value-get-abrupt.js | 74 +++++++++++++++ .../named-yield-star-next-get-abrupt.js | 64 +++++++++++++ ...yield-star-next-non-object-ignores-then.js | 84 ++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 61 ++++++++++++ ...yield-star-next-not-callable-null-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-number-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-object-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-string-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 61 ++++++++++++ ...-star-next-not-callable-undefined-throw.js | 61 ++++++++++++ .../named-yield-star-next-then-get-abrupt.js | 88 +++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 82 ++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 82 ++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 82 ++++++++++++++++ ...med-yield-star-next-then-returns-abrupt.js | 88 +++++++++++++++++ .../yield-star-next-call-done-get-abrupt.js | 72 ++++++++++++++ .../yield-star-next-call-returns-abrupt.js | 64 +++++++++++++ .../yield-star-next-call-value-get-abrupt.js | 74 +++++++++++++++ .../yield-star-next-get-abrupt.js | 64 +++++++++++++ ...yield-star-next-non-object-ignores-then.js | 84 ++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 61 ++++++++++++ ...yield-star-next-not-callable-null-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-number-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-object-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-string-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 61 ++++++++++++ ...-star-next-not-callable-undefined-throw.js | 61 ++++++++++++ .../yield-star-next-then-get-abrupt.js | 88 +++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 82 ++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 82 ++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 82 ++++++++++++++++ .../yield-star-next-then-returns-abrupt.js | 88 +++++++++++++++++ ...ic-yield-star-next-call-done-get-abrupt.js | 79 +++++++++++++++ ...tic-yield-star-next-call-returns-abrupt.js | 71 ++++++++++++++ ...c-yield-star-next-call-value-get-abrupt.js | 81 ++++++++++++++++ ...ethod-static-yield-star-next-get-abrupt.js | 71 ++++++++++++++ ...yield-star-next-non-object-ignores-then.js | 91 ++++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 68 +++++++++++++ ...yield-star-next-not-callable-null-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-number-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-object-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-string-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 68 +++++++++++++ ...-star-next-not-callable-undefined-throw.js | 68 +++++++++++++ ...-static-yield-star-next-then-get-abrupt.js | 95 +++++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 89 +++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 89 +++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 89 +++++++++++++++++ ...tic-yield-star-next-then-returns-abrupt.js | 95 +++++++++++++++++++ ...od-yield-star-next-call-done-get-abrupt.js | 79 +++++++++++++++ ...hod-yield-star-next-call-returns-abrupt.js | 71 ++++++++++++++ ...d-yield-star-next-call-value-get-abrupt.js | 81 ++++++++++++++++ ...c-gen-method-yield-star-next-get-abrupt.js | 71 ++++++++++++++ ...yield-star-next-non-object-ignores-then.js | 91 ++++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 68 +++++++++++++ ...yield-star-next-not-callable-null-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-number-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-object-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-string-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 68 +++++++++++++ ...-star-next-not-callable-undefined-throw.js | 68 +++++++++++++ ...-method-yield-star-next-then-get-abrupt.js | 95 +++++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 89 +++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 89 +++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 89 +++++++++++++++++ ...hod-yield-star-next-then-returns-abrupt.js | 95 +++++++++++++++++++ ...en-yield-star-next-call-done-get-abrupt.js | 72 ++++++++++++++ ...gen-yield-star-next-call-returns-abrupt.js | 64 +++++++++++++ ...n-yield-star-next-call-value-get-abrupt.js | 74 +++++++++++++++ .../async-gen-yield-star-next-get-abrupt.js | 64 +++++++++++++ ...yield-star-next-non-object-ignores-then.js | 84 ++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 61 ++++++++++++ ...yield-star-next-not-callable-null-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-number-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-object-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-string-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 61 ++++++++++++ ...-star-next-not-callable-undefined-throw.js | 61 ++++++++++++ ...ync-gen-yield-star-next-then-get-abrupt.js | 88 +++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 82 ++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 82 ++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 82 ++++++++++++++++ ...gen-yield-star-next-then-returns-abrupt.js | 88 +++++++++++++++++ .../yield-star-next-call-done-get-abrupt.js | 72 ++++++++++++++ .../yield-star-next-call-returns-abrupt.js | 64 +++++++++++++ .../yield-star-next-call-value-get-abrupt.js | 74 +++++++++++++++ .../yield-star-next-get-abrupt.js | 64 +++++++++++++ ...yield-star-next-non-object-ignores-then.js | 84 ++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 61 ++++++++++++ ...yield-star-next-not-callable-null-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-number-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-object-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-string-throw.js | 61 ++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 61 ++++++++++++ ...-star-next-not-callable-undefined-throw.js | 61 ++++++++++++ .../yield-star-next-then-get-abrupt.js | 88 +++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 82 ++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 82 ++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 82 ++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 82 ++++++++++++++++ .../yield-star-next-then-returns-abrupt.js | 88 +++++++++++++++++ ...ic-yield-star-next-call-done-get-abrupt.js | 79 +++++++++++++++ ...tic-yield-star-next-call-returns-abrupt.js | 71 ++++++++++++++ ...c-yield-star-next-call-value-get-abrupt.js | 81 ++++++++++++++++ ...ethod-static-yield-star-next-get-abrupt.js | 71 ++++++++++++++ ...yield-star-next-non-object-ignores-then.js | 91 ++++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 68 +++++++++++++ ...yield-star-next-not-callable-null-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-number-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-object-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-string-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 68 +++++++++++++ ...-star-next-not-callable-undefined-throw.js | 68 +++++++++++++ ...-static-yield-star-next-then-get-abrupt.js | 95 +++++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 89 +++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 89 +++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 89 +++++++++++++++++ ...tic-yield-star-next-then-returns-abrupt.js | 95 +++++++++++++++++++ ...od-yield-star-next-call-done-get-abrupt.js | 79 +++++++++++++++ ...hod-yield-star-next-call-returns-abrupt.js | 71 ++++++++++++++ ...d-yield-star-next-call-value-get-abrupt.js | 81 ++++++++++++++++ ...c-gen-method-yield-star-next-get-abrupt.js | 71 ++++++++++++++ ...yield-star-next-non-object-ignores-then.js | 91 ++++++++++++++++++ ...ld-star-next-not-callable-boolean-throw.js | 68 +++++++++++++ ...yield-star-next-not-callable-null-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-number-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-object-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-string-throw.js | 68 +++++++++++++ ...eld-star-next-not-callable-symbol-throw.js | 68 +++++++++++++ ...-star-next-not-callable-undefined-throw.js | 68 +++++++++++++ ...-method-yield-star-next-then-get-abrupt.js | 95 +++++++++++++++++++ ...hen-non-callable-boolean-fulfillpromise.js | 89 +++++++++++++++++ ...t-then-non-callable-null-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-number-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-object-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-string-fulfillpromise.js | 89 +++++++++++++++++ ...then-non-callable-symbol-fulfillpromise.js | 89 +++++++++++++++++ ...n-non-callable-undefined-fulfillpromise.js | 89 +++++++++++++++++ ...hod-yield-star-next-then-returns-abrupt.js | 95 +++++++++++++++++++ 168 files changed, 12868 insertions(+) create mode 100644 test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-get-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-get-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-get-abrupt.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..a983cf4cd5 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting done (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..0dcffdf401 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while calling next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..bb072bb3e2 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..e4b7bdd8f0 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js b/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..081f9a31c1 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: If next() value is not-object, do not access respective then property (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..99a9e326f2 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - boolean (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..f0ad070fd6 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - null (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..c6c28e3a74 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - number (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..45b7aee7d0 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - object (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..3b48b33b93 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - string (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..58b697b586 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - symbol (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..eec2fd2f69 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - undefined (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..1ba4fd88eb --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after getting next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..6f5c95af4e --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..b223de5bf2 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..c995892b98 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..2b9925d996 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..ec4b195a5d --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..fcefe679da --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..76a8b7b92a --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..715883c430 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after calling next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..d4f3c92221 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting done (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..25ba0d7adb --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while calling next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..0f81e4fef7 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..64553662aa --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js b/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..775391dcd5 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression.template +/*--- +description: If next() value is not-object, do not access respective then property (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..e6bf37f887 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - boolean (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..1cc10d2afe --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - null (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..04737bcb12 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - number (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..dae130da84 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - object (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..c07e55cd7e --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - string (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..6eb39b2024 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - symbol (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..5a4e50258f --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - undefined (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..4af4b57672 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after getting next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..0c685accb3 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..d6919d6e76 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..ee3a16ac58 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..0610e3f3f2 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..6d2b3b9ab1 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..86d5c8a710 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..17ad83c612 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js b/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..4391180d1c --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after calling next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..89e0163347 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..f2972dc1f1 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..2c4e517f59 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..30d17b536d --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..47f1aa0e66 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..abc2f3b8e8 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..1cb37d6792 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..7c34852b71 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..aed54bd2c3 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..6f5e6b0374 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..8ff634774c --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..cdc1c8adc2 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..7f117b6b74 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..bef481f83c --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..8f27218b8f --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..acefe92b02 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..95a5a782d7 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..c358cdab04 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..ae2dc4be0e --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..82abbf1f4e --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..7444f65698 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..62ece3d7e3 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting done (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..d47fe096ac --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while calling next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..802c617306 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..3b69bae809 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..2bee89cbc2 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..75d6fa8cab --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..abf7fa7eb4 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..e305ad4dde --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..e84eb94ac0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..c39891b853 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..970ae58679 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..0f12fa6620 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..fd0c8bc4c5 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..2975d1bec2 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..2700e425d0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..d0e25849d2 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..0b2420c1f6 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..87472a33aa --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..b03b7fd2d9 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..6e038598dc --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..d34cfc2e98 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..bd8ff99b1d --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting done (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..ffbd025ab1 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while calling next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..266eeb21bc --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..23f86cb393 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..5e154af2b7 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..c4546d18ee --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..12f5d296ee --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..dbb1ae94d9 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..7fddd5bd23 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..62cf039282 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..07fc007f64 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..9fad5f605f --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..77943229e4 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..755b9068f8 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..47faa7471a --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..fc74bf7942 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..cd9d211867 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..f3f7a18268 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..3322d59b91 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..38a1641585 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..b69abcfabc --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..c13ed8b6ee --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting done (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..32d9bb485f --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while calling next (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..07a2fabc71 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..a03caa2457 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting next (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js b/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..4731c17dbe --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-declaration.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..4cb2ca81e6 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..60d8eaaf7f --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..7dec927b81 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..1c70464a1c --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..3a9ff2b1d0 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..7b57f326a3 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..496680b6f2 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..15e2451787 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Return abrupt after getting next().then (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..e4baa841fe --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..bb6b53dbac --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..898cb85c7b --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..a1cf875767 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..a9de651f5d --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..9b7414d03b --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..76b7307eb9 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js b/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..18d1b45231 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Return abrupt after calling next().then (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..53ae856b4d --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..d0c2b5d6d7 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..96ecd99ad8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..621ee58ceb --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..db0d0499e9 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..9989ea6d41 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..b0c14146e2 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..13d8ce91bf --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..4263df16a8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..0974eb5dae --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..6098c1c85b --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..67b0e6d5ab --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..5cce8661a8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..f141e2e8fc --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..d322511143 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..bff54ade5b --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..7203befcf0 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..a219952e33 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..7b6799bedb --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..64c19d4bca --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..91f4648919 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..e4c670ff19 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting done (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..c1660b888c --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while calling next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..04ead08fda --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..ede7d25b9d --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..dd4a92ba15 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..bb7ae18717 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..79032029b4 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..f16689a758 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..2a210a4822 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..f8bc989bd8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..7c39e43f31 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..334f8fe170 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..8151a2af33 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after getting next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..275c1f79ff --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..fbfdaff67d --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..cb08503ac6 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..137156769e --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..2e15e7ad93 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..ee4e4dba3a --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..21dfa1d6a5 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..d1cafe17cc --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after calling next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + 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); -- GitLab