From c3c8d6f099c7d24f650016bc91611ec9f233e723 Mon Sep 17 00:00:00 2001 From: Rick Waldron <waldron.rick@gmail.com> Date: Wed, 3 May 2017 11:03:51 -0400 Subject: [PATCH] for-await-of: dstr-binding, error, async func & async gen templates Signed-off-by: Rick Waldron <waldron.rick@gmail.com> --- .../for-await-of-async-func-const.template | 48 ++++++++++++ .../for-await-of-async-func-let.template | 48 ++++++++++++ .../for-await-of-async-func-var.template | 47 +++++++++++ .../for-await-of-async-gen-const.template | 48 ++++++++++++ .../error/for-await-of-async-gen-let.template | 47 +++++++++++ .../error/for-await-of-async-gen-var.template | 48 ++++++++++++ ...c-func-dstr-const-ary-init-iter-get-err.js | 60 +++++++++++++++ ...c-dstr-const-ary-ptrn-elem-ary-val-null.js | 67 ++++++++++++++++ ...dstr-const-ary-ptrn-elem-id-init-throws.js | 58 ++++++++++++++ ...onst-ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++++++++ ...tr-const-ary-ptrn-elem-id-iter-step-err.js | 66 ++++++++++++++++ ...str-const-ary-ptrn-elem-id-iter-val-err.js | 77 +++++++++++++++++++ ...c-dstr-const-ary-ptrn-elem-obj-val-null.js | 67 ++++++++++++++++ ...-dstr-const-ary-ptrn-elem-obj-val-undef.js | 67 ++++++++++++++++ ...nc-dstr-const-ary-ptrn-elision-step-err.js | 74 ++++++++++++++++++ ...const-ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++++++++ ...tr-const-ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++++++++ ...str-const-ary-ptrn-rest-id-iter-val-err.js | 73 ++++++++++++++++++ .../async-func-dstr-const-obj-init-null.js | 54 +++++++++++++ ...sync-func-dstr-const-obj-init-undefined.js | 54 +++++++++++++ ...nc-dstr-const-obj-ptrn-id-get-value-err.js | 61 +++++++++++++++ ...func-dstr-const-obj-ptrn-id-init-throws.js | 61 +++++++++++++++ ...str-const-obj-ptrn-id-init-unresolvable.js | 65 ++++++++++++++++ ...async-func-dstr-const-obj-ptrn-list-err.js | 62 +++++++++++++++ ...dstr-const-obj-ptrn-prop-ary-value-null.js | 56 ++++++++++++++ ...-func-dstr-const-obj-ptrn-prop-eval-err.js | 58 ++++++++++++++ ...tr-const-obj-ptrn-prop-id-get-value-err.js | 63 +++++++++++++++ ...dstr-const-obj-ptrn-prop-id-init-throws.js | 61 +++++++++++++++ ...onst-obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++++++++ ...dstr-const-obj-ptrn-prop-obj-value-null.js | 56 ++++++++++++++ ...str-const-obj-ptrn-prop-obj-value-undef.js | 56 ++++++++++++++ ...ync-func-dstr-let-ary-init-iter-get-err.js | 60 +++++++++++++++ ...unc-dstr-let-ary-ptrn-elem-ary-val-null.js | 67 ++++++++++++++++ ...c-dstr-let-ary-ptrn-elem-id-init-throws.js | 58 ++++++++++++++ ...-let-ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++++++++ ...dstr-let-ary-ptrn-elem-id-iter-step-err.js | 66 ++++++++++++++++ ...-dstr-let-ary-ptrn-elem-id-iter-val-err.js | 77 +++++++++++++++++++ ...unc-dstr-let-ary-ptrn-elem-obj-val-null.js | 67 ++++++++++++++++ ...nc-dstr-let-ary-ptrn-elem-obj-val-undef.js | 67 ++++++++++++++++ ...func-dstr-let-ary-ptrn-elision-step-err.js | 74 ++++++++++++++++++ ...r-let-ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++++++++ ...dstr-let-ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++++++++ ...-dstr-let-ary-ptrn-rest-id-iter-val-err.js | 73 ++++++++++++++++++ .../async-func-dstr-let-obj-init-null.js | 54 +++++++++++++ .../async-func-dstr-let-obj-init-undefined.js | 54 +++++++++++++ ...func-dstr-let-obj-ptrn-id-get-value-err.js | 61 +++++++++++++++ ...c-func-dstr-let-obj-ptrn-id-init-throws.js | 61 +++++++++++++++ ...-dstr-let-obj-ptrn-id-init-unresolvable.js | 65 ++++++++++++++++ .../async-func-dstr-let-obj-ptrn-list-err.js | 62 +++++++++++++++ ...c-dstr-let-obj-ptrn-prop-ary-value-null.js | 56 ++++++++++++++ ...nc-func-dstr-let-obj-ptrn-prop-eval-err.js | 58 ++++++++++++++ ...dstr-let-obj-ptrn-prop-id-get-value-err.js | 63 +++++++++++++++ ...c-dstr-let-obj-ptrn-prop-id-init-throws.js | 61 +++++++++++++++ ...-let-obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++++++++ ...c-dstr-let-obj-ptrn-prop-obj-value-null.js | 56 ++++++++++++++ ...-dstr-let-obj-ptrn-prop-obj-value-undef.js | 56 ++++++++++++++ ...ync-func-dstr-var-ary-init-iter-get-err.js | 59 ++++++++++++++ ...unc-dstr-var-ary-ptrn-elem-ary-val-null.js | 66 ++++++++++++++++ ...c-dstr-var-ary-ptrn-elem-id-init-throws.js | 57 ++++++++++++++ ...-var-ary-ptrn-elem-id-init-unresolvable.js | 64 +++++++++++++++ ...dstr-var-ary-ptrn-elem-id-iter-step-err.js | 65 ++++++++++++++++ ...-dstr-var-ary-ptrn-elem-id-iter-val-err.js | 76 ++++++++++++++++++ ...unc-dstr-var-ary-ptrn-elem-obj-val-null.js | 66 ++++++++++++++++ ...nc-dstr-var-ary-ptrn-elem-obj-val-undef.js | 66 ++++++++++++++++ ...func-dstr-var-ary-ptrn-elision-step-err.js | 73 ++++++++++++++++++ ...r-var-ary-ptrn-rest-id-elision-next-err.js | 59 ++++++++++++++ ...dstr-var-ary-ptrn-rest-id-iter-step-err.js | 70 +++++++++++++++++ ...-dstr-var-ary-ptrn-rest-id-iter-val-err.js | 72 +++++++++++++++++ .../async-func-dstr-var-obj-init-null.js | 53 +++++++++++++ .../async-func-dstr-var-obj-init-undefined.js | 53 +++++++++++++ ...func-dstr-var-obj-ptrn-id-get-value-err.js | 60 +++++++++++++++ ...c-func-dstr-var-obj-ptrn-id-init-throws.js | 60 +++++++++++++++ ...-dstr-var-obj-ptrn-id-init-unresolvable.js | 64 +++++++++++++++ .../async-func-dstr-var-obj-ptrn-list-err.js | 61 +++++++++++++++ ...c-dstr-var-obj-ptrn-prop-ary-value-null.js | 55 +++++++++++++ ...nc-func-dstr-var-obj-ptrn-prop-eval-err.js | 57 ++++++++++++++ ...dstr-var-obj-ptrn-prop-id-get-value-err.js | 62 +++++++++++++++ ...c-dstr-var-obj-ptrn-prop-id-init-throws.js | 60 +++++++++++++++ ...-var-obj-ptrn-prop-id-init-unresolvable.js | 64 +++++++++++++++ ...c-dstr-var-obj-ptrn-prop-obj-value-null.js | 55 +++++++++++++ ...-dstr-var-obj-ptrn-prop-obj-value-undef.js | 55 +++++++++++++ ...nc-gen-dstr-const-ary-init-iter-get-err.js | 60 +++++++++++++++ ...n-dstr-const-ary-ptrn-elem-ary-val-null.js | 67 ++++++++++++++++ ...dstr-const-ary-ptrn-elem-id-init-throws.js | 58 ++++++++++++++ ...onst-ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++++++++ ...tr-const-ary-ptrn-elem-id-iter-step-err.js | 66 ++++++++++++++++ ...str-const-ary-ptrn-elem-id-iter-val-err.js | 77 +++++++++++++++++++ ...n-dstr-const-ary-ptrn-elem-obj-val-null.js | 67 ++++++++++++++++ ...-dstr-const-ary-ptrn-elem-obj-val-undef.js | 67 ++++++++++++++++ ...en-dstr-const-ary-ptrn-elision-step-err.js | 74 ++++++++++++++++++ ...const-ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++++++++ ...tr-const-ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++++++++ ...str-const-ary-ptrn-rest-id-iter-val-err.js | 73 ++++++++++++++++++ .../async-gen-dstr-const-obj-init-null.js | 54 +++++++++++++ ...async-gen-dstr-const-obj-init-undefined.js | 54 +++++++++++++ ...en-dstr-const-obj-ptrn-id-get-value-err.js | 61 +++++++++++++++ ...-gen-dstr-const-obj-ptrn-id-init-throws.js | 61 +++++++++++++++ ...str-const-obj-ptrn-id-init-unresolvable.js | 65 ++++++++++++++++ .../async-gen-dstr-const-obj-ptrn-list-err.js | 62 +++++++++++++++ ...dstr-const-obj-ptrn-prop-ary-value-null.js | 56 ++++++++++++++ ...c-gen-dstr-const-obj-ptrn-prop-eval-err.js | 58 ++++++++++++++ ...tr-const-obj-ptrn-prop-id-get-value-err.js | 63 +++++++++++++++ ...dstr-const-obj-ptrn-prop-id-init-throws.js | 61 +++++++++++++++ ...onst-obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++++++++ ...dstr-const-obj-ptrn-prop-obj-value-null.js | 56 ++++++++++++++ ...str-const-obj-ptrn-prop-obj-value-undef.js | 56 ++++++++++++++ ...sync-gen-dstr-let-ary-init-iter-get-err.js | 59 ++++++++++++++ ...gen-dstr-let-ary-ptrn-elem-ary-val-null.js | 66 ++++++++++++++++ ...n-dstr-let-ary-ptrn-elem-id-init-throws.js | 57 ++++++++++++++ ...-let-ary-ptrn-elem-id-init-unresolvable.js | 64 +++++++++++++++ ...dstr-let-ary-ptrn-elem-id-iter-step-err.js | 65 ++++++++++++++++ ...-dstr-let-ary-ptrn-elem-id-iter-val-err.js | 76 ++++++++++++++++++ ...gen-dstr-let-ary-ptrn-elem-obj-val-null.js | 66 ++++++++++++++++ ...en-dstr-let-ary-ptrn-elem-obj-val-undef.js | 66 ++++++++++++++++ ...-gen-dstr-let-ary-ptrn-elision-step-err.js | 73 ++++++++++++++++++ ...r-let-ary-ptrn-rest-id-elision-next-err.js | 59 ++++++++++++++ ...dstr-let-ary-ptrn-rest-id-iter-step-err.js | 70 +++++++++++++++++ ...-dstr-let-ary-ptrn-rest-id-iter-val-err.js | 72 +++++++++++++++++ .../async-gen-dstr-let-obj-init-null.js | 53 +++++++++++++ .../async-gen-dstr-let-obj-init-undefined.js | 53 +++++++++++++ ...-gen-dstr-let-obj-ptrn-id-get-value-err.js | 60 +++++++++++++++ ...nc-gen-dstr-let-obj-ptrn-id-init-throws.js | 60 +++++++++++++++ ...-dstr-let-obj-ptrn-id-init-unresolvable.js | 64 +++++++++++++++ .../async-gen-dstr-let-obj-ptrn-list-err.js | 61 +++++++++++++++ ...n-dstr-let-obj-ptrn-prop-ary-value-null.js | 55 +++++++++++++ ...ync-gen-dstr-let-obj-ptrn-prop-eval-err.js | 57 ++++++++++++++ ...dstr-let-obj-ptrn-prop-id-get-value-err.js | 62 +++++++++++++++ ...n-dstr-let-obj-ptrn-prop-id-init-throws.js | 60 +++++++++++++++ ...-let-obj-ptrn-prop-id-init-unresolvable.js | 64 +++++++++++++++ ...n-dstr-let-obj-ptrn-prop-obj-value-null.js | 55 +++++++++++++ ...-dstr-let-obj-ptrn-prop-obj-value-undef.js | 55 +++++++++++++ ...sync-gen-dstr-var-ary-init-iter-get-err.js | 60 +++++++++++++++ ...gen-dstr-var-ary-ptrn-elem-ary-val-null.js | 67 ++++++++++++++++ ...n-dstr-var-ary-ptrn-elem-id-init-throws.js | 58 ++++++++++++++ ...-var-ary-ptrn-elem-id-init-unresolvable.js | 65 ++++++++++++++++ ...dstr-var-ary-ptrn-elem-id-iter-step-err.js | 66 ++++++++++++++++ ...-dstr-var-ary-ptrn-elem-id-iter-val-err.js | 77 +++++++++++++++++++ ...gen-dstr-var-ary-ptrn-elem-obj-val-null.js | 67 ++++++++++++++++ ...en-dstr-var-ary-ptrn-elem-obj-val-undef.js | 67 ++++++++++++++++ ...-gen-dstr-var-ary-ptrn-elision-step-err.js | 74 ++++++++++++++++++ ...r-var-ary-ptrn-rest-id-elision-next-err.js | 60 +++++++++++++++ ...dstr-var-ary-ptrn-rest-id-iter-step-err.js | 71 +++++++++++++++++ ...-dstr-var-ary-ptrn-rest-id-iter-val-err.js | 73 ++++++++++++++++++ .../async-gen-dstr-var-obj-init-null.js | 54 +++++++++++++ .../async-gen-dstr-var-obj-init-undefined.js | 54 +++++++++++++ ...-gen-dstr-var-obj-ptrn-id-get-value-err.js | 61 +++++++++++++++ ...nc-gen-dstr-var-obj-ptrn-id-init-throws.js | 61 +++++++++++++++ ...-dstr-var-obj-ptrn-id-init-unresolvable.js | 65 ++++++++++++++++ .../async-gen-dstr-var-obj-ptrn-list-err.js | 62 +++++++++++++++ ...n-dstr-var-obj-ptrn-prop-ary-value-null.js | 56 ++++++++++++++ ...ync-gen-dstr-var-obj-ptrn-prop-eval-err.js | 58 ++++++++++++++ ...dstr-var-obj-ptrn-prop-id-get-value-err.js | 63 +++++++++++++++ ...n-dstr-var-obj-ptrn-prop-id-init-throws.js | 61 +++++++++++++++ ...-var-obj-ptrn-prop-id-init-unresolvable.js | 65 ++++++++++++++++ ...n-dstr-var-obj-ptrn-prop-obj-value-null.js | 56 ++++++++++++++ ...-dstr-var-obj-ptrn-prop-obj-value-undef.js | 56 ++++++++++++++ 156 files changed, 9698 insertions(+) create mode 100644 src/dstr-binding/error/for-await-of-async-func-const.template create mode 100644 src/dstr-binding/error/for-await-of-async-func-let.template create mode 100644 src/dstr-binding/error/for-await-of-async-func-var.template create mode 100644 src/dstr-binding/error/for-await-of-async-gen-const.template create mode 100644 src/dstr-binding/error/for-await-of-async-gen-let.template create mode 100644 src/dstr-binding/error/for-await-of-async-gen-var.template create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js diff --git a/src/dstr-binding/error/for-await-of-async-func-const.template b/src/dstr-binding/error/for-await-of-async-func-const.template new file mode 100644 index 0000000000..dc2fc2499b --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-const.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function fn() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-func-let.template b/src/dstr-binding/error/for-await-of-async-func-let.template new file mode 100644 index 0000000000..291b51a648 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-let.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function fn() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-func-var.template b/src/dstr-binding/error/for-await-of-async-func-var.template new file mode 100644 index 0000000000..ab9ae97124 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-func-var.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function fn() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-const.template b/src/dstr-binding/error/for-await-of-async-gen-const.template new file mode 100644 index 0000000000..4f4f2deb0f --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-const.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function * gen() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding/error/for-await-of-async-gen-let.template b/src/dstr-binding/error/for-await-of-async-gen-let.template new file mode 100644 index 0000000000..38c2f00fbc --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-let.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function * gen() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); diff --git a/src/dstr-binding/error/for-await-of-async-gen-var.template b/src/dstr-binding/error/for-await-of-async-gen-var.template new file mode 100644 index 0000000000..41f9d08a27 --- /dev/null +++ b/src/dstr-binding/error/for-await-of-async-gen-var.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +async function * gen() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000..9da24dcf7e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (const [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..bb387d3285 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (const [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..bd15ae9270 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function fn() { + for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..699df9e6a7 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..b0f6240e72 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (const [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..201883140d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (const [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..5dbb8aae09 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (const [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..f57a737bfb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (const [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..fd42bfbe9b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (const [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..3314200498 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (const [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..5c428cb60b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (const [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..3e8d5d7a67 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (const [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js new file mode 100644 index 0000000000..ea28e8223a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (const {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000..60afada464 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (const {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..e5f578fd10 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (const { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..acf8199fc5 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..160c8fd48e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000..1354691d8e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..1bfc8b26af --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..560b7b727f --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..2dd96d03bf --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..9b3445c284 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (const { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..f8b2c3f3ae --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (const { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..fc16686aa5 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..90450b19cb --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (const { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000..12b62c4772 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (let [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..b87926ec43 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (let [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..f9b468dac1 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function fn() { + for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..d683743e9c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..42e47aa5bd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (let [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..ebf0dbe427 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (let [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..3e9dcbe7cd --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (let [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..10178b11e8 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (let [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..1cf324585c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (let [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..73ccf728c4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (let [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..9bc64fa008 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (let [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..511fa2bb47 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (let [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js new file mode 100644 index 0000000000..955bd17e83 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (let {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000..450b7227f2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (let {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..1e77d91be6 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (let { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..3fbf30fb2d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..180a4bf765 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000..e52ef1ce70 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..9e5b06c3f9 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..783753532d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..426855dcac --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..9c769ad08e --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (let { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..31ecf590f7 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (let { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..214ab9ad23 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..83d4fe737b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (let { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000..cfa5cb4bfe --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function fn() { + for await (var [x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..6d255ef275 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function fn() { + for await (var [[x]] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..50dfb1f4a4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function fn() { + for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..8843287483 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var [ x = unresolvableReference ] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..6ec536b76c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function fn() { + for await (var [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..e9ffc53df2 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (var [x] of [g]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..441e5083d3 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (var [{ x }] of [[null]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..f0c5f2a395 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function fn() { + for await (var [{ x }] of [[]]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..e479c08304 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function fn() { + for await (var [,] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..11d946d86b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function fn() { + for await (var [, ...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..0505025f63 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function fn() { + for await (var [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..db39511b8a --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function fn() { + for await (var [...x] of [iter]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js new file mode 100644 index 0000000000..09d1a4ecce --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (var {} of [null]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000..c088bb341c --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function fn() { + for await (var {} of [undefined]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..5c5902f244 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (var { poisoned } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..4b220333ed --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { x = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..291a8cc4da --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var { x = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000..bcf36faf02 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..93646baf3d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..d680fe914d --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { [thrower()]: x } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..e23a739d40 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function fn() { + for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..8c7240cde4 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function fn() { + for await (var { x: y = thrower() } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..a31720a485 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function fn() { + for await (var { x: y = unresolvableReference } of [{}]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..6f90b69395 --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..8c8036684b --- /dev/null +++ b/test/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-func-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function fn() { + for await (var { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +fn() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000..1862861721 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (const [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..a3a90b88fa --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (const [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..8c0e96fba6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function * gen() { + for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..a2d02f2c16 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..eb45be31ce --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (const [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..f22a8b721e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (const [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..72157c912b --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (const [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..60ea181cee --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (const [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..d4704ce5ec --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (const [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..58ffcd6f64 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (const [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..57dd0e59cd --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (const [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..182e1242b1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (const [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js new file mode 100644 index 0000000000..f033632b8a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (const {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000..122c83a140 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (const {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..7453f3c166 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (const { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..3ddbba3de5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..e608f96f39 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000..c902df24b8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..08361ef67a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..39e7585c8d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..ac75fdbaac --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..ec2c87bd53 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (const { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..1e579b0266 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (const { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..e1870cbe3d --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..db09efb8f6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (const { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000..46741b80e0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (let [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..8cb11d7d93 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (let [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..d5cd68a9d6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function * gen() { + for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..9c2d1f4e0c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1329aeb034 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (let [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..ac90a30a4f --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (let [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..01423ae155 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (let [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..6af6d06f55 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (let [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..b5a858877c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (let [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..fba96bfa78 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (let [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..cadf333dab --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (let [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..251a49afb7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (let [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js new file mode 100644 index 0000000000..4c1b77e1a7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (let {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000..31254fe61c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (let {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..02e34625eb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (let { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..b769bf1032 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..6ef453222a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000..c4fa1f25ae --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..3c32db5539 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..3cf4177b6a --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..1692345a66 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..3271a5dfa9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (let { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..e831ea42e6 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (let { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..e23a1bb9e9 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..82e71ea931 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (let { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000..a74a3b5d96 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Abrupt completion returned by GetIterator (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +async function * gen() { + for await (var [x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..a8ab29bbcc --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested array destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +async function * gen() { + for await (var [[x]] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..267d3362e0 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +async function * gen() { + for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..ac20681ef8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var [ x = unresolvableReference ] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1a0c0ce0c2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +async function * gen() { + for await (var [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..9d764066f4 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (var [x] of [g]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..7ca17a4126 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested object destructuring with a null value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (var [{ x }] of [[null]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a2ef24f31c --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Nested object destructuring with a value of `undefined` (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +async function * gen() { + for await (var [{ x }] of [[]]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..27b0231dbe --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +async function * gen() { + for await (var [,] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..cde00838d2 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Rest element following elision elements (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +async function * gen() { + for await (var [, ...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..63e8ed66d7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [generators, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +async function * gen() { + for await (var [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..a68cc73128 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [Symbol.iterator, destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +async function * gen() { + for await (var [...x] of [iter]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js new file mode 100644 index 0000000000..db7e73ba92 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (var {} of [null]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000..21b565b2bb --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +async function * gen() { + for await (var {} of [undefined]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..20a4466681 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (var { poisoned } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..b24aac79e7 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { x = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..36c561c4d1 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var { x = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000..ce5ff77d47 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..be9556f0f8 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..0f682cbaf5 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { [thrower()]: x } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..496b7fb325 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +async function * gen() { + for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..a03dcad4f3 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Error thrown when evaluating the initializer (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +async function * gen() { + for await (var { x: y = thrower() } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, Test262Error)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..2da010c159 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +async function * gen() { + for await (var { x: y = unresolvableReference } of [{}]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, ReferenceError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..17ad2d3f61 --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + diff --git a/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..20a1a2213e --- /dev/null +++ b/test/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-await-of-async-gen-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [generated, async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +async function * gen() { + for await (var { w: { x, y, z } = undefined } of [{ }]) { + return; + } +} + +gen().next() + .then(_ => throw new Test262Error("Expected async function to reject, but resolved."), ({ constructor }) => assert.sameValue(constructor, TypeError)) + .then($DONE, $DONE); + -- GitLab